/* ==========================================================================
   History 화면 : 2002 → 2024 반도체 회로 맵 + 연도별 과제 목록
   - 왼쪽  .afcs-circuit  연도 칩(IC 패키지)과 회로 배선 (칩은 history-circuit.js 가 생성)
   - 오른쪽 .afcs-ledger   선택한 연도의 과제 목록

   칩은 사방에 핀이 달린 IC 패키지(QFP) 모양이다. 핀과 1번 핀 표식은 이미지 없이
   CSS 그라데이션만으로 그리고, 핀 끝에는 회로선(SVG)이 비아(동그란 패드)로 연결된다.
   색은 최대한 절제해서 평소에는 회색 / 선택 경로는 포인트 노란색으로만 표현한다.
   ========================================================================== */
.afcs-circuit {
    --afcs-circuit-cols: 4;
    --afcs-circuit-gap-x: 36px;     /* 칩 사이 가로 간격 (핀 + 비아 + 배선이 들어갈 자리) */
    --afcs-circuit-gap-y: 46px;     /* 칩 사이 세로 간격 */
    --afcs-pin-length: 6px;         /* 핀이 몸체 밖으로 나온 길이 (history-circuit.js 도 이 값을 읽는다) */
    position: relative;
    padding: 18px 14px;
}

/* 세로가 긴 화면(모바일, 태블릿 세로, 피벗 세로 모니터 등)에서는 그림 상 · 내용 하로 쌓는다 */
@media (max-width: 991px), (max-aspect-ratio: 11 / 10) {
    #view-history .afcs-split--divided {
        grid-template-columns: minmax(0, 1fr);
    }

    #view-history .afcs-split--divided > :first-child {
        padding-right: 0;
    }

    #view-history .afcs-split--divided > :last-child {
        margin-top: 36px;
        padding-top: 36px;
        padding-left: 0;
        border-top: 1px solid var(--afcs-line);
        border-left: 0;
    }

    #view-history .afcs-ledger {
        position: static;
    }

    #view-history .afcs-circuit {
        --afcs-circuit-cols: 6;
        --afcs-circuit-gap-x: 30px;
        --afcs-circuit-gap-y: 34px;
    }

    #view-history .afcs-circuit__chip {
        height: 48px;
        line-height: 46px;
    }
}

@media (max-width: 767px) {
    #view-history .afcs-circuit {
        --afcs-circuit-cols: 4;
        --afcs-circuit-gap-x: 28px;
        --afcs-circuit-gap-y: 30px;
    }

    #view-history .afcs-circuit__chip {
        height: 46px;
        line-height: 44px;
    }
}

@media (max-width: 479px) {
    #view-history .afcs-circuit {
        --afcs-circuit-cols: 3;
        --afcs-circuit-gap-x: 24px;
        --afcs-circuit-gap-y: 28px;
    }

    #view-history .afcs-circuit__chip {
        height: 44px;
        line-height: 42px;
        font-size: 14.5px;
    }
}

/* --------------------------------------------------------------------------
   회로 배선 (SVG) : 얇은 회색 배선 + 선택한 연도까지는 노란색, 끝마다 비아 패드
   -------------------------------------------------------------------------- */
.afcs-circuit__traces {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.afcs-circuit__trace {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.afcs-circuit__trace--base {
    stroke: var(--afcs-line-strong);
    stroke-width: 2;
}

.afcs-circuit__trace--active {
    stroke: var(--afcs-accent);
    stroke-width: 2.5;
}

.afcs-circuit__via {
    stroke-width: 1.5;
}

.afcs-circuit__via--base {
    fill: var(--afcs-surface);
    stroke: var(--afcs-line-strong);
}

.afcs-circuit__via--active {
    fill: var(--afcs-accent);
    stroke: var(--afcs-accent);
}

/* --------------------------------------------------------------------------
   연도 칩 = IC 패키지
   --chip-body  몸체 색   --chip-mark  테두리 · 노치 · 1번 핀 표식 색   --chip-pin  핀 색
   -------------------------------------------------------------------------- */
.afcs-circuit__chips {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(var(--afcs-circuit-cols), minmax(0, 1fr));
    gap: var(--afcs-circuit-gap-y) var(--afcs-circuit-gap-x);
    margin: 0;
    padding: 0;
}

.afcs-circuit__chip {
    --chip-border: 1.5px;
    --chip-body: var(--afcs-surface);
    --chip-mark: var(--afcs-line-strong);
    --chip-pin: #bdc1c6;
    --chip-ink: var(--afcs-muted);
    --pin-reach: calc(var(--afcs-pin-length) + var(--chip-border));   /* 테두리 바깥까지 닿는 핀 길이 */

    position: relative;
    display: block;
    width: 100%;
    height: 54px;
    padding: 0;
    color: var(--chip-ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 16px;
    font-weight: 700;
    line-height: 52px;
    letter-spacing: 1px;
    text-align: center;
    cursor: pointer;
    background-color: var(--chip-body);
    /* 위쪽 가운데 반원 노치 + 왼쪽 위 1번 핀 표식(점) */
    background-image:
        radial-gradient(circle at 50% 0, var(--chip-mark) 0 4px, transparent 4.5px),
        radial-gradient(circle at 10px 11px, var(--chip-mark) 0 2px, transparent 2.5px);
    border: var(--chip-border) solid var(--chip-mark);
    border-radius: 4px;
    transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

/* 위 · 아래 핀 7개 (가운데 핀이 세로 배선과 만난다) */
.afcs-circuit__chip::before {
    content: "";
    position: absolute;
    top: calc(var(--pin-reach) * -1);
    bottom: calc(var(--pin-reach) * -1);
    left: 50%;
    width: 56px;
    margin-left: -28px;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent 2px, var(--chip-pin) 0 6px, transparent 0) 0 0 / 8px var(--pin-reach) repeat-x,
        linear-gradient(90deg, transparent 2px, var(--chip-pin) 0 6px, transparent 0) 0 100% / 8px var(--pin-reach) repeat-x;
}

/* 왼쪽 · 오른쪽 핀 3개 (가운데 핀이 가로 배선과 만난다) */
.afcs-circuit__chip::after {
    content: "";
    position: absolute;
    left: calc(var(--pin-reach) * -1);
    right: calc(var(--pin-reach) * -1);
    top: 50%;
    height: 24px;
    margin-top: -12px;
    pointer-events: none;
    background:
        linear-gradient(180deg, transparent 2px, var(--chip-pin) 0 6px, transparent 0) 0 0 / var(--pin-reach) 8px repeat-y,
        linear-gradient(180deg, transparent 2px, var(--chip-pin) 0 6px, transparent 0) 100% 0 / var(--pin-reach) 8px repeat-y;
}

.afcs-circuit__chip:hover {
    --chip-mark: var(--afcs-ink);
    --chip-pin: var(--afcs-muted);
}

.afcs-circuit__chip:focus-visible {
    outline: 2px solid var(--afcs-ink);
    outline-offset: 10px;
}

/* 2002 → 선택한 연도까지 : 전원이 들어온 것처럼 몸체 선은 진하게, 핀은 노란색 */
.afcs-circuit__chip.is-powered {
    --chip-mark: var(--afcs-ink);
    --chip-pin: var(--afcs-accent);
    --chip-ink: var(--afcs-ink);
}

/* 현재 선택한 연도 : 칠하지 않고 글자만 노란색으로 표시 */
.afcs-circuit__chip.is-active {
    --chip-ink: var(--afcs-accent);
}

/* --------------------------------------------------------------------------
   오른쪽 열 : 스크롤해도 따라오는(sticky) 과제 목록
   -------------------------------------------------------------------------- */
.afcs-history__detail {
    min-width: 0;
}

.afcs-ledger {
    position: sticky;
    top: calc(var(--afcs-nav-height) + 24px);
    scroll-margin-top: calc(var(--afcs-nav-height) + 16px);
    padding: 0;   /* 기존 테마의 section { padding: 120px 0 } 를 덮어쓴다 */
}

.afcs-ledger__year {
    margin: 0 0 8px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--afcs-ink);
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.6px;
    color: var(--afcs-ink);
    text-transform: none;
}

.afcs-project {
    padding: 28px 0;
    border-bottom: 1px solid var(--afcs-line);
    word-break: keep-all;
}

.afcs-project:last-child {
    border-bottom: 0;
}

.afcs-project__title {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--afcs-ink);
    text-transform: none;
}

.afcs-project__list {
    margin: 0;
    padding: 0;
}

.afcs-project__list > li {
    position: relative;
    padding-left: 14px;
    font-size: 15.5px;
    line-height: 1.85;
    color: var(--afcs-muted);
}

.afcs-project__list > li::before {
    content: "–";
    position: absolute;
    left: 0;
}
