/* namu.club — Hyangmok Hoe (향목회)
 * Palette: terracotta-warm-cypress
 *   #1F1410 jet bark | #3A2418 heartwood | #C46A3A tannin terracotta
 *   #9A6B3F resin amber | #5C7A4E cypress shade | #D7C9A8 paper-aged
 *   #7A5A3E foxed page
 * Type: Cormorant Garamond, Noto Serif KR, IBM Plex Mono, Eczar
 */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    background: #1F1410;
    color: #D7C9A8;
    font-family: 'IBM Plex Mono', monospace;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    position: relative;
}

/* Tree-ring underprint, fixed at z-index -1, 6% opacity */
.tree-ring-underprint {
    position: fixed;
    top: 50%;
    left: 50%;
    width: min(140vmax, 1800px);
    height: min(140vmax, 1800px);
    transform: translate(-50%, -50%);
    opacity: 0.06;
    z-index: -1;
    pointer-events: none;
}

/* Corner vignette: 4% radial darkening at the four corners */
.vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
    background:
        radial-gradient(ellipse at top    left,  rgba(0,0,0,0.18), transparent 40%),
        radial-gradient(ellipse at top    right, rgba(0,0,0,0.18), transparent 40%),
        radial-gradient(ellipse at bottom left,  rgba(0,0,0,0.18), transparent 40%),
        radial-gradient(ellipse at bottom right, rgba(0,0,0,0.18), transparent 40%);
}

/* ----- Hex base shape ----- */
.hex {
    --hex-w: 132px;
    --hex-h: calc(var(--hex-w) * 1.1547); /* pointy-top: h = w * 2/sqrt(3) */
    width: var(--hex-w);
    height: var(--hex-h);
    background: #1F1410;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 22% 12%;
    text-align: center;
    text-decoration: none;
    color: #D7C9A8;
    cursor: default;
    box-shadow: inset 0 0 8px rgba(58, 36, 24, 0.6);
}

/* Cell wall — drawn as a layered border using a slightly larger
 * heartwood-coloured pseudo, then the cell sits on top. */
.hex::before {
    content: "";
    position: absolute;
    inset: -2px;
    background: rgba(58, 36, 24, 0.6);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    z-index: -1;
}

/* ===========================================================
 * Cambium border — top 18vh
 * =========================================================== */

.cambium-border {
    position: relative;
    height: 18vh;
    min-height: 130px;
    width: 100%;
    background: #1F1410;
    border-bottom: 1px solid rgba(58, 36, 24, 0.7);
    overflow: hidden;
    z-index: 5;
}

.pit-pair-pattern {
    position: absolute;
    inset: 0;
    opacity: 0.09;
    pointer-events: none;
    animation: pit-shimmer 14s ease-in-out infinite;
}

@keyframes pit-shimmer {
    0%, 100% { opacity: 0.07; }
    50%      { opacity: 0.11; }
}

.committee-row {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 4vw;
    z-index: 2;
}

.committee-hex {
    --hex-w: 110px;
    background: #1F1410;
    cursor: pointer;
    transition: background 240ms ease;
    overflow: hidden;
}

.committee-hex .committee-name {
    font-family: 'Noto Serif KR', serif;
    font-size: 22px;
    font-weight: 500;
    color: #D7C9A8;
    letter-spacing: 0.04em;
    line-height: 1;
    margin-bottom: 4px;
}

.committee-hex .committee-kr {
    font-family: 'Noto Serif KR', serif;
    font-size: 12px;
    font-weight: 500;
    color: #D7C9A8;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.committee-hex .committee-chair {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    color: #C46A3A;
    letter-spacing: 0.02em;
    margin-top: 6px;
    opacity: 0;
    transform: translateX(40%);
    transition: opacity 240ms ease, transform 240ms ease;
    text-transform: lowercase;
    white-space: nowrap;
}

.committee-hex:hover .committee-chair,
.committee-hex.is-active .committee-chair {
    opacity: 1;
    transform: translateX(0);
}

.committee-hex.is-active {
    background: #3A2418;
}

.committee-hex.is-active::after {
    content: "";
    position: absolute;
    bottom: 18%;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background: #C46A3A;
    border-radius: 50%;
}

/* ===========================================================
 * Phloem channel — left 8vw, fixed
 * =========================================================== */

.phloem-channel {
    position: fixed;
    top: 18vh;
    bottom: 22vh;
    left: 0;
    width: 8vw;
    min-width: 84px;
    z-index: 30;
    pointer-events: none;
}

.phloem-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(50% - 2px);
    width: 4px;
    background:
        repeating-linear-gradient(
            to bottom,
            #9A6B3F 0px,
            #9A6B3F 6px,
            rgba(154, 107, 63, 0.74) 6px,
            rgba(154, 107, 63, 0.74) 9px
        );
    opacity: 0.92;
}

.year-rings {
    position: relative;
    list-style: none;
    height: 100%;
    pointer-events: auto;
}

.ring-mark {
    position: absolute;
    left: 0;
    width: 100%;
    transform: translateY(-50%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 12%;
}

.ring-mark .cross {
    display: inline-block;
    width: 28px;
    height: 2px;
    background: #C46A3A;
    flex-shrink: 0;
    margin-right: 10px;
    transition: width 240ms ease, background 240ms ease;
}

.ring-mark .year-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9.5px;
    color: #7A5A3E;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    white-space: nowrap;
    transition: color 240ms ease, opacity 240ms ease;
    opacity: 0.78;
}

.ring-mark:hover .cross,
.ring-mark.active .cross {
    width: 40px;
    background: #C46A3A;
}

.ring-mark:hover .year-label {
    color: #D7C9A8;
    opacity: 1;
}

.ring-mark.active .year-label {
    color: #C46A3A;
    opacity: 1;
}

/* ===========================================================
 * Member field — the honeycomb proper
 * =========================================================== */

.member-field {
    position: relative;
    margin-left: 8vw;
    margin-right: 0;
    padding: 36px 24px 36px 24px;
    min-height: 60vh;
    z-index: 4;
}

.honeycomb {
    --hex-w: 132px;
    --hex-h: calc(var(--hex-w) * 1.1547);
    --row-spacing: calc(var(--hex-h) * 0.75);
    --col-spacing: calc(var(--hex-w) + 4px);

    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fill, var(--col-spacing));
    grid-auto-rows: var(--row-spacing);
    justify-content: center;
    transition: transform 720ms cubic-bezier(0.32, 0.72, 0.24, 1),
                opacity 720ms cubic-bezier(0.32, 0.72, 0.24, 1);
    will-change: transform, opacity;
}

.honeycomb.sliding {
    opacity: 0.35;
}

.member-hex {
    --hex-w: 132px;
    perspective: 800px;
    background: transparent;
    box-shadow: none;
    padding: 0;
    clip-path: none;
    cursor: pointer;
}

.member-hex::before {
    display: none;
}

/* Offset every other row for honeycomb tiling */
.honeycomb > .member-hex:nth-child(odd-row) {
    /* placeholder; offsets applied via JS-set inline grid-column */
}

.cell-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 420ms cubic-bezier(0.32, 0.72, 0.24, 1);
    transform-style: preserve-3d;
}

.member-hex:hover .cell-inner {
    transform: rotateY(180deg);
}

.cell-face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: #1F1410;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    box-shadow: inset 0 0 8px rgba(58, 36, 24, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 22% 12%;
    text-align: center;
}

.cell-face::before {
    content: "";
    position: absolute;
    inset: -2px;
    background: rgba(58, 36, 24, 0.6);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    z-index: -1;
}

.cell-face-back {
    transform: rotateY(180deg);
    background: #3A2418;
}

.cell-glyph {
    width: 38%;
    aspect-ratio: 1 / 1;
    display: block;
    margin-bottom: 4px;
}

.cell-glyph svg {
    width: 100%;
    height: 100%;
    display: block;
}

.cell-handle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 400;
    color: #D7C9A8;
    letter-spacing: 0.02em;
    line-height: 1;
    text-transform: lowercase;
    margin-top: 2px;
}

.cell-mark {
    font-family: 'Eczar', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 10.5px;
    line-height: 1.35;
    color: #7A5A3E;
    margin-top: 4px;
    max-width: 100%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cell-back-handle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11.5px;
    color: #D7C9A8;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    margin-bottom: 6px;
}

.cell-back-year {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: #C46A3A;
    letter-spacing: 0.04em;
}

.cell-back-committee {
    font-family: 'Noto Serif KR', serif;
    font-size: 11px;
    color: #D7C9A8;
    margin-top: 4px;
    letter-spacing: 0.04em;
}

/* Knot cells — 1 in 23, darker, hold longer note (no flip) */
.member-hex.knot .cell-face {
    background: #3A2418;
    box-shadow: inset 0 0 14px rgba(31, 20, 16, 0.75);
}
.member-hex.knot .cell-face::before {
    background: rgba(31, 20, 16, 0.85);
}

.member-hex.knot .cell-glyph {
    width: 28%;
}

.member-hex.knot .knot-note {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 10.5px;
    line-height: 1.45;
    color: #D7C9A8;
    margin-top: 4px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.member-hex.knot:hover .cell-inner {
    transform: none;
}

/* Patina — per-decade saturation reduction */
.member-hex[data-decade="0"]  .cell-face { filter: saturate(1);     }
.member-hex[data-decade="1"]  .cell-face { filter: saturate(0.96);  }
.member-hex[data-decade="2"]  .cell-face { filter: saturate(0.92);  }
.member-hex[data-decade="3"]  .cell-face { filter: saturate(0.88);  }
.member-hex[data-decade="4"]  .cell-face { filter: saturate(0.84);  }
.member-hex[data-decade="5"]  .cell-face { filter: saturate(0.80);  }
.member-hex[data-decade="6"]  .cell-face { filter: saturate(0.76);  }
.member-hex[data-decade="7"]  .cell-face { filter: saturate(0.72);  }
.member-hex[data-decade="8"]  .cell-face { filter: saturate(0.68);  }
.member-hex[data-decade="9"]  .cell-face { filter: saturate(0.64);  }

/* ===========================================================
 * Marrow footer — bottom 22vh
 * =========================================================== */

.marrow-footer {
    height: 22vh;
    min-height: 180px;
    width: 100%;
    background: #1F1410;
    border-top: 1px solid rgba(58, 36, 24, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    position: relative;
}

.motto-row {
    display: flex;
    flex-direction: row;
    gap: 6px;
    padding: 0 5vw;
    align-items: center;
    justify-content: center;
}

.motto-hex {
    --hex-w: 150px;
    cursor: default;
}

.motto-hex .motto-kr {
    font-family: 'Noto Serif KR', serif;
    font-size: 18px;
    font-weight: 400;
    color: #D7C9A8;
    line-height: 1.6;
    letter-spacing: 0.12em;
    text-align: center;
}

.motto-hex .motto-la {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 11px;
    color: #7A5A3E;
    margin-top: 4px;
    letter-spacing: 0.04em;
    text-align: center;
}

/* ===========================================================
 * Cmd-click zoom overlay
 * =========================================================== */

.zoom-overlay {
    position: fixed;
    inset: 0;
    background: rgba(31, 20, 16, 0);
    pointer-events: none;
    z-index: 100;
    transition: background 1200ms cubic-bezier(0.32, 0.72, 0.24, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-overlay.active {
    background: rgba(31, 20, 16, 0.92);
    pointer-events: auto;
}

.zoom-stage {
    position: relative;
    width: 70vmin;
    height: 70vmin;
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 1200ms cubic-bezier(0.32, 0.72, 0.24, 1),
                transform 1200ms cubic-bezier(0.32, 0.72, 0.24, 1);
}

.zoom-overlay.active .zoom-stage {
    opacity: 1;
    transform: scale(1);
}

.zoom-stage .zoom-cell {
    position: absolute;
    inset: 0;
    background: #1F1410;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    box-shadow: inset 0 0 30px #3A2418;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18% 14%;
    text-align: center;
}

.zoom-stage .zoom-cell::before {
    content: "";
    position: absolute;
    inset: -3px;
    background: rgba(58, 36, 24, 0.6);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    z-index: -1;
}

/* Pit-pair micropattern inside the zoomed cell */
.zoom-stage .pit-pattern {
    position: absolute;
    inset: 6%;
    pointer-events: none;
    opacity: 0.16;
}

.zoom-stage .zoom-glyph {
    width: 30%;
    aspect-ratio: 1 / 1;
    margin-bottom: 14px;
    z-index: 2;
}
.zoom-stage .zoom-glyph svg {
    width: 100%;
    height: 100%;
}

.zoom-stage .zoom-handle {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    color: #D7C9A8;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    z-index: 2;
}

.zoom-stage .zoom-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: #C46A3A;
    margin-top: 6px;
    letter-spacing: 0.04em;
    z-index: 2;
}

.zoom-stage .zoom-note {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 13pt;
    line-height: 22px;
    color: #D7C9A8;
    margin-top: 16px;
    max-width: 84%;
    z-index: 2;
}

.zoom-stage .zoom-hint {
    position: absolute;
    bottom: -36px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9.5px;
    color: #7A5A3E;
    letter-spacing: 0.06em;
    text-transform: lowercase;
}

/* ===========================================================
 * Status caption
 * =========================================================== */

.status-caption {
    position: fixed;
    top: 20vh;
    left: 12vw;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    color: #C46A3A;
    letter-spacing: 0.06em;
    text-transform: lowercase;
    opacity: 0;
    transition: opacity 600ms ease;
    z-index: 50;
    pointer-events: none;
}

.status-caption.visible {
    opacity: 1;
}

/* ===========================================================
 * Tablet
 * =========================================================== */

@media (max-width: 1024px) {
    .hex { --hex-w: 88px; }
    .committee-hex { --hex-w: 76px; }
    .motto-hex { --hex-w: 110px; }
    .honeycomb { --hex-w: 88px; }
    .member-hex { --hex-w: 88px; }
    .cell-handle { font-size: 9.5px; }
    .cell-mark { font-size: 9px; -webkit-line-clamp: 2; }
    .motto-hex .motto-kr { font-size: 14px; }
    .motto-hex .motto-la { font-size: 9.5px; }
    .committee-hex .committee-name { font-size: 18px; }
    .committee-hex .committee-kr  { font-size: 10px; }
    .committee-hex .committee-chair { font-size: 8px; }
}

/* ===========================================================
 * Phone
 * =========================================================== */

@media (max-width: 640px) {
    .hex { --hex-w: 64px; }
    .committee-hex { --hex-w: 58px; }
    .motto-hex { --hex-w: 84px; }
    .honeycomb { --hex-w: 64px; }
    .member-hex { --hex-w: 64px; }
    .phloem-channel { width: 14vw; }
    .member-field { margin-left: 14vw; padding: 18px 8px; }
    .cell-handle { font-size: 8px; }
    .cell-mark { font-size: 7.5px; }
    .motto-hex .motto-kr { font-size: 11px; letter-spacing: 0.06em; }
    .motto-hex .motto-la { font-size: 8px; }
    .committee-hex .committee-name { font-size: 13px; }
    .committee-hex .committee-kr  { font-size: 8px; }
    .committee-hex .committee-chair { font-size: 6.5px; }
    .committee-row { gap: 2px; padding: 0 2vw; }
    .motto-row { gap: 2px; padding: 0 2vw; }
    .ring-mark .year-label { font-size: 8px; }
    .ring-mark .cross { width: 18px; }
}

/* ===========================================================
 * Reduced motion
 * =========================================================== */

@media (prefers-reduced-motion: reduce) {
    .pit-pair-pattern { animation: none; }
    .member-hex:hover .cell-inner { transform: none; }
    .member-hex .cell-inner { transition: opacity 200ms ease; }
    .honeycomb { transition: transform 0ms; }
}
