/* ============================================
   namu.club — Watercolor Immersive Codex
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    background-color: #F4ECE0;
    color: #5A4A38;
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    line-height: 1.85;
    overflow-x: hidden;
    position: relative;
}

/* --- Watercolor Wash Layers --- */
.watercolor-wash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    transition: opacity 1.2s ease;
}

.wash-sepia {
    background:
        radial-gradient(ellipse 80% 60% at 20% 30%, rgba(138, 122, 96, 0.12) 0%, transparent 70%),
        radial-gradient(ellipse 60% 80% at 75% 65%, rgba(90, 74, 56, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 90% 40% at 50% 90%, rgba(216, 200, 168, 0.15) 0%, transparent 50%);
    opacity: 1;
}

.wash-blue {
    background:
        radial-gradient(ellipse 70% 70% at 30% 40%, rgba(100, 120, 160, 0.08) 0%, transparent 65%),
        radial-gradient(ellipse 50% 90% at 80% 20%, rgba(100, 120, 160, 0.06) 0%, transparent 55%),
        radial-gradient(ellipse 80% 50% at 60% 75%, rgba(120, 140, 170, 0.07) 0%, transparent 60%);
    opacity: 0;
}

.wash-green {
    background:
        radial-gradient(ellipse 60% 80% at 25% 55%, rgba(100, 140, 100, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 80% 50% at 70% 30%, rgba(100, 140, 100, 0.06) 0%, transparent 55%),
        radial-gradient(ellipse 50% 70% at 50% 80%, rgba(110, 150, 110, 0.07) 0%, transparent 50%);
    opacity: 0;
}

/* --- Parchment Grain Texture --- */
.parchment-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    opacity: 0.5;
}

/* --- Typography --- */
.annotation {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    color: #8A7A60;
    font-size: 1.05rem;
}

h1, h2, h3 {
    font-family: 'JetBrains Mono', monospace;
    color: #2A2018;
}

.body-text {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    color: #5A4A38;
    font-size: clamp(0.85rem, 1vw, 0.95rem);
    line-height: 1.85;
    max-width: 52ch;
}

/* --- Underline-Draw Interaction --- */
.underline-draw {
    background-image: linear-gradient(#4A3828, #4A3828);
    background-position: 0 100%;
    background-repeat: no-repeat;
    background-size: 0% 1.5px;
    transition: background-size 250ms ease;
    padding-bottom: 2px;
    display: inline;
    cursor: default;
}

.underline-draw:hover,
.underline-draw.drawn {
    background-size: 100% 1.5px;
}

/* ============================================
   CODEX OPENING
   ============================================ */
.codex-opening {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 6vh 0;
}

.opening-field {
    display: grid;
    grid-template-columns: 80px 1fr 80px;
    max-width: 900px;
    width: 90%;
    margin: 0 auto;
    gap: 0;
}

.opening-margin-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 2rem;
    gap: 1rem;
}

.opening-margin-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 2rem;
}

.margin-rule {
    width: 2px;
    height: 120px;
    opacity: 0.5;
}

.margin-note {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.15em;
    font-size: 0.95rem;
}

.opening-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding-left: 2vw;
    gap: 3rem;
}

.title-cluster {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.above-title {
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    opacity: 0;
    transform: translateY(8px);
    animation: fadeInUp 0.8s ease 0.3s forwards;
}

.codex-title {
    font-size: clamp(2.8rem, 7vw, 5.5rem);
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #2A2018;
    line-height: 1;
    opacity: 0;
    animation: fadeIn 1s ease 0.6s forwards;
}

.title-underline {
    width: 0;
    height: 2px;
    background-color: #4A3828;
    animation: drawLine 0.8s ease 1.2s forwards;
}

.codex-subtitle {
    font-weight: 300;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    color: #5A4A38;
    line-height: 1.6;
    opacity: 0;
    animation: fadeInUp 0.8s ease 1.6s forwards;
}

/* --- Opening Isometric Icons --- */
.isometric-array {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.iso-icon {
    width: 48px;
    height: 48px;
    opacity: 0;
    animation: fadeIn 0.6s ease forwards;
    transition: transform 0.3s ease;
}

.opening-icons .iso-icon:nth-child(1) { animation-delay: 2s; }
.opening-icons .iso-icon:nth-child(2) { animation-delay: 2.2s; }
.opening-icons .iso-icon:nth-child(3) { animation-delay: 2.4s; }

/* --- Scroll Hint --- */
.scroll-hint {
    position: absolute;
    bottom: 4vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    animation: fadeIn 0.6s ease 2.8s forwards;
}

.scroll-arrow {
    width: 20px;
    height: 30px;
    animation: bobDown 2s ease-in-out infinite;
}

/* ============================================
   CODEX CHAPTERS
   ============================================ */
.codex-chapter {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 60px 1fr;
    max-width: 950px;
    width: 90%;
    margin: 0 auto;
    padding: 10vh 0;
    gap: 0;
}

.chapter-gutter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding-top: 0.5rem;
}

.gutter-line {
    width: 1px;
    flex-grow: 1;
    min-height: 60px;
    background: linear-gradient(to bottom, transparent, #D8C8A8 15%, #D8C8A8 85%, transparent);
}

.gutter-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.9rem;
    letter-spacing: 0.15em;
}

.chapter-body {
    padding-left: 2vw;
}

.chapter-heading {
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    font-weight: 700;
    margin-bottom: 2.5rem;
    letter-spacing: 0.04em;
}

.heading-text {
    display: inline;
}

/* --- Layered-Depth Panels --- */
.layered-panel {
    position: relative;
    margin-bottom: 2rem;
}

.panel-shadow-layer {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 100%;
    height: 100%;
    background-color: #D8C8A8;
    border: 1px solid #D8C8A8;
    transition: transform 0.3s ease;
}

.panel-shadow-layer-2 {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 100%;
    height: 100%;
    background-color: #D8C8A8;
    opacity: 0.5;
    border: 1px solid #D8C8A8;
    transition: transform 0.3s ease;
}

.panel-face {
    position: relative;
    background-color: #F4ECE0;
    border: 1px solid #8A7A60;
    padding: 2.5rem 3rem;
    z-index: 1;
    transition: transform 0.3s ease;
}

.layered-panel:hover .panel-shadow-layer {
    transform: translate(2px, 2px);
}

.layered-panel:hover .panel-shadow-layer-2 {
    transform: translate(2px, 2px);
}

.layered-panel:hover .panel-face {
    transform: translate(-2px, -2px);
}

.panel-annotation {
    display: block;
    margin-top: 1.5rem;
    text-align: right;
}

/* --- Chapter I: About --- */
#chapterAbout .chapter-body {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

#chapterAbout .chapter-icons {
    padding-left: 1rem;
}

#panelAbout .body-text + .body-text {
    margin-top: 1rem;
}

/* ============================================
   CHAPTER II: METHODOLOGY
   ============================================ */
.methodology-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2.5rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 700px) {
    .methodology-grid {
        grid-template-columns: 1.2fr 0.9fr 1fr;
        gap: 1.8rem 2.5rem;
    }

    .method-panel:nth-child(2) {
        margin-top: 3rem;
    }

    .method-panel:nth-child(3) {
        margin-top: 1.2rem;
    }
}

.method-panel .panel-face {
    padding: 2rem 2rem;
}

.method-number {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3rem);
    color: #D8C8A8;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.method-title {
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: 0.06em;
}

.method-panel .body-text {
    font-size: clamp(0.8rem, 0.9vw, 0.88rem);
}

.section-annotation {
    display: block;
    text-align: right;
    font-size: 1rem;
}

/* ============================================
   CHAPTER III: FOLIOS
   ============================================ */
.folio-entries {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.folio-entry {
    padding: 2.5rem 0;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.folio-entry.visible {
    opacity: 1;
    transform: translateY(0);
}

.folio-date {
    font-size: 0.95rem;
    margin-bottom: 0.6rem;
    display: block;
}

.folio-title {
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    font-weight: 700;
    margin-bottom: 0.8rem;
    letter-spacing: 0.02em;
}

.folio-border {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, #D8C8A8, #8A7A60 50%, #D8C8A8);
    opacity: 0.6;
}

.folio-entry:last-child .folio-border {
    display: none;
}

/* Staggered folio indentation — manuscript-margin rhythm */
.folio-entry:nth-child(2) {
    padding-left: 3rem;
}

.folio-entry:nth-child(3) {
    padding-left: 1.2rem;
}

/* Folio hover shift */
.folio-entry {
    transition: opacity 0.6s ease, transform 0.6s ease, padding-left 0.3s ease;
}

.folio-entry:hover {
    padding-left: 1rem;
}

.folio-entry:nth-child(2):hover {
    padding-left: 4rem;
}

.folio-entry:nth-child(3):hover {
    padding-left: 2.2rem;
}

/* ============================================
   CHAPTER IV: CONTRIBUTORS
   ============================================ */
.contributors-panel .panel-face {
    padding: 3rem;
}

.contributor-list {
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
    margin-top: 2rem;
}

.contributor {
    display: flex;
    align-items: flex-start;
    gap: 1.2rem;
}

.contributor-mark {
    font-size: 0.7rem;
    color: #6A5A40;
    margin-top: 0.35rem;
    flex-shrink: 0;
}

.contributor-name {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: #2A2018;
    font-size: clamp(0.9rem, 1.1vw, 1rem);
    margin-bottom: 0.15rem;
}

.contributor .annotation {
    display: block;
    font-size: 0.95rem;
    line-height: 1.4;
}

#chapterContributors .chapter-body {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.contributor-icons {
    padding-left: 1rem;
}

/* ============================================
   COLOPHON
   ============================================ */
.codex-colophon {
    position: relative;
    z-index: 2;
    max-width: 950px;
    width: 90%;
    margin: 0 auto;
    padding: 8vh 0 12vh;
}

.colophon-rule {
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, transparent, #8A7A60 30%, #8A7A60 70%, transparent);
    margin-bottom: 3rem;
}

.colophon-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
}

.colophon-text {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    color: #5A4A38;
    font-size: clamp(0.78rem, 0.9vw, 0.85rem);
    line-height: 1.85;
    max-width: 48ch;
}

.colophon-sigil {
    margin: 1rem 0;
}

.sigil-mark {
    width: 60px;
    height: 60px;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes drawLine {
    from { width: 0; }
    to { width: min(300px, 60%); }
}

@keyframes bobDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(5px); }
}

/* ============================================
   SCROLL REVEAL STATES
   ============================================ */
.layered-panel {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.layered-panel.visible {
    opacity: 1;
    transform: translateY(0);
}

.chapter-icons,
.contributor-icons {
    opacity: 0;
    transition: opacity 0.8s ease 0.3s;
}

.chapter-icons.visible,
.contributor-icons.visible {
    opacity: 1;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
    .opening-field {
        grid-template-columns: 40px 1fr 40px;
    }

    .codex-chapter {
        grid-template-columns: 40px 1fr;
    }

    .panel-face {
        padding: 1.8rem 1.5rem;
    }

    .contributors-panel .panel-face {
        padding: 2rem 1.5rem;
    }

    .methodology-grid {
        gap: 2rem;
    }

    .margin-note {
        font-size: 0.8rem;
    }
}

/* --- Watercolor Ink Blot Decorations --- */
.codex-chapter::before {
    content: '';
    position: absolute;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
}

#chapterAbout::before {
    top: -40px;
    right: -60px;
    background: radial-gradient(ellipse at center, rgba(138, 122, 96, 0.06) 0%, transparent 70%);
}

#chapterMethodology::before {
    top: 20%;
    left: -80px;
    width: 220px;
    height: 220px;
    background: radial-gradient(ellipse at center, rgba(100, 120, 160, 0.05) 0%, transparent 70%);
}

#chapterFolios::before {
    bottom: 10%;
    right: -50px;
    background: radial-gradient(ellipse at center, rgba(100, 140, 100, 0.05) 0%, transparent 70%);
}

#chapterContributors::before {
    top: -30px;
    left: -70px;
    width: 200px;
    height: 200px;
    background: radial-gradient(ellipse at center, rgba(90, 74, 56, 0.05) 0%, transparent 70%);
}

/* --- Watercolor Ink Wash on Opening --- */
.codex-opening::after {
    content: '';
    position: absolute;
    bottom: -40px;
    left: 10%;
    width: 80%;
    height: 80px;
    background: radial-gradient(ellipse at center, rgba(216, 200, 168, 0.25) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

/* --- Folio entry left accent line --- */
.folio-entry::before {
    content: '';
    position: absolute;
    top: 2.5rem;
    left: 0;
    width: 3px;
    height: 0;
    background-color: #D8C8A8;
    transition: height 0.4s ease 0.2s;
}

.folio-entry.visible::before {
    height: calc(100% - 3rem);
}

/* --- Selection color --- */
::selection {
    background-color: rgba(216, 200, 168, 0.5);
    color: #2A2018;
}
