/* ============================================================
   hinagiku.dev — Tidal Circuit Design
   Colors: #1A2E28 (deep bg), #2D4A3E (mid bg), #7BC4B0 (teal accent),
           #C8A96E (amber), #D4B896 (warm sand), #A67C52 (copper),
           #E8D5A3 (light amber), #ffffff (white)
   Fonts: Roboto Slab 300/700, Source Serif 4 400
   ============================================================ */

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

:root {
    --deep-bg:    #1A2E28;
    --mid-bg:     #2D4A3E;
    --teal:       #7BC4B0;
    --amber:      #C8A96E;
    --sand:       #D4B896;
    --copper:     #A67C52;
    --light-amber:#E8D5A3;
    --pale-amber: #F5EDD8;
    --white:      #ffffff;
    --black:      #000000;

    --font-display: 'Roboto Slab', serif;
    --font-body:    'Source Serif 4', serif;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background: var(--deep-bg);
    color: var(--sand);
    font-family: var(--font-body);
    font-weight: 400;
    overflow-x: hidden;
}

/* ---- Navigation ---- */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 48px;
    display: flex;
    align-items: center;
    padding: 0 2.5rem;
    transition: background 0.4s ease, opacity 0.4s ease;
    opacity: 0.85;
}

.site-nav.scrolled {
    background: rgba(26, 46, 40, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(123, 196, 176, 0.12);
}

.nav-inner {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-mark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--teal);
    letter-spacing: 0.08em;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 0.72rem;
    color: var(--sand);
    text-decoration: none;
    letter-spacing: 0.12em;
    text-transform: lowercase;
    opacity: 0.65;
    transition: opacity 0.2s, color 0.2s;
}

.nav-links a:hover {
    opacity: 1;
    color: var(--teal);
}

/* ---- Sections — Diagonal Stack ---- */
.section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Diagonal clip-path cuts — each section overlaps the next */
.emerge {
    background: var(--deep-bg);
    clip-path: polygon(0 0, 100% 0, 100% 92%, 0 100%);
    margin-bottom: -6vh;
    z-index: 5;
    min-height: 100vh;
}

.surface {
    background: linear-gradient(160deg, var(--mid-bg) 0%, #223D35 60%, var(--deep-bg) 100%);
    clip-path: polygon(0 4%, 100% 0, 100% 94%, 0 100%);
    margin-bottom: -6vh;
    z-index: 4;
    min-height: 100vh;
    padding: 8vh 0;
}

.depth {
    background: linear-gradient(150deg, #162822 0%, var(--deep-bg) 50%, #0F1E1A 100%);
    clip-path: polygon(0 4%, 100% 0, 100% 93%, 0 100%);
    margin-bottom: -6vh;
    z-index: 3;
    min-height: 100vh;
    padding: 10vh 0;
}

.current {
    background: linear-gradient(140deg, var(--mid-bg) 0%, #1E3830 70%, var(--deep-bg) 100%);
    clip-path: polygon(0 5%, 100% 0, 100% 94%, 0 100%);
    margin-bottom: -6vh;
    z-index: 2;
    min-height: 100vh;
    padding: 12vh 0;
}

.stillness {
    background: var(--deep-bg);
    clip-path: polygon(0 5%, 100% 0, 100% 100%, 0 100%);
    z-index: 1;
    min-height: 100vh;
    padding: 14vh 0;
}

/* ---- Section 1: Emerge ---- */
.emerge-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 80% at 50% 60%, rgba(200, 169, 110, 0.08) 0%, transparent 70%),
        radial-gradient(ellipse 40% 40% at 50% 50%, rgba(123, 196, 176, 0.04) 0%, transparent 60%);
}

/* Grain noise overlay */
.emerge-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    opacity: 0.4;
    pointer-events: none;
}

.circuit-daisy-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, 80vw);
    height: min(420px, 80vw);
    display: flex;
    align-items: center;
    justify-content: center;
}

.circuit-daisy {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 18px rgba(123, 196, 176, 0.25)) drop-shadow(0 0 4px rgba(200, 169, 110, 0.15));
    animation: daisy-breathe 6s ease-in-out infinite;
    transform-origin: 50% 50%;
}

@keyframes daisy-breathe {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.9; }
    50%       { transform: scale(1.025) rotate(0.5deg); opacity: 1; }
}

.petal-trace {
    stroke-dasharray: 120;
    stroke-dashoffset: 120;
    animation: trace-draw 3s ease-out forwards;
}

.petal-trace:nth-child(1)  { animation-delay: 0.1s; }
.petal-trace:nth-child(3)  { animation-delay: 0.25s; }
.petal-trace:nth-child(5)  { animation-delay: 0.4s; }
.petal-trace:nth-child(7)  { animation-delay: 0.55s; }
.petal-trace:nth-child(9)  { animation-delay: 0.7s; }
.petal-trace:nth-child(11) { animation-delay: 0.85s; }
.petal-trace:nth-child(13) { animation-delay: 1.0s; }
.petal-trace:nth-child(15) { animation-delay: 1.15s; }

@keyframes trace-draw {
    to { stroke-dashoffset: 0; }
}

.trace-node {
    animation: node-appear 0.3s ease-out forwards;
    opacity: 0;
}

.trace-node:nth-child(2)  { animation-delay: 0.8s; }
.trace-node:nth-child(4)  { animation-delay: 0.95s; }
.trace-node:nth-child(6)  { animation-delay: 1.1s; }
.trace-node:nth-child(8)  { animation-delay: 1.25s; }
.trace-node:nth-child(10) { animation-delay: 1.4s; }
.trace-node:nth-child(12) { animation-delay: 1.55s; }
.trace-node:nth-child(14) { animation-delay: 1.7s; }
.trace-node:nth-child(16) { animation-delay: 1.85s; }

@keyframes node-appear {
    0%   { opacity: 0; r: 0; }
    100% { opacity: 1; r: 3; }
}

.daisy-core {
    animation: core-glow 4s ease-in-out infinite;
}

@keyframes core-glow {
    0%, 100% { filter: drop-shadow(0 0 6px rgba(200, 169, 110, 0.5)); }
    50%       { filter: drop-shadow(0 0 14px rgba(200, 169, 110, 0.8)); }
}

.circuit-ring {
    animation: ring-spin 40s linear infinite;
    transform-origin: 200px 200px;
}

.circuit-ring-outer {
    animation: ring-spin 80s linear infinite reverse;
    transform-origin: 200px 200px;
}

@keyframes ring-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.emerge-text {
    position: absolute;
    bottom: 18vh;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.emerge-label {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.5em;
    color: var(--teal);
    opacity: 0.6;
    text-transform: uppercase;
    animation: fade-up 2s ease-out 1.5s both;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 0.6; transform: translateY(0); }
}

.scroll-signal {
    position: absolute;
    bottom: 5vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fade-up 2s ease-out 2s both;
}

.scroll-line {
    display: block;
    width: 1px;
    height: 48px;
    background: linear-gradient(to bottom, transparent, var(--teal), transparent);
    animation: scroll-pulse 2.4s ease-in-out infinite;
}

@keyframes scroll-pulse {
    0%, 100% { opacity: 0.3; transform: scaleY(0.6); }
    50%       { opacity: 0.8; transform: scaleY(1); }
}

/* ---- Section 2: Surface ---- */
.surface-inner {
    text-align: left;
    padding: 0 8vw;
    max-width: 1100px;
    width: 100%;
}

.domain-display {
    display: flex;
    align-items: baseline;
    gap: 0.3em;
    margin-bottom: 1.2rem;
}

.domain-pre {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--teal);
    opacity: 0.5;
    letter-spacing: -0.02em;
}

.domain-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(3.5rem, 10vw, 9rem);
    color: var(--light-amber);
    letter-spacing: 0.04em;
    line-height: 1;
    opacity: 0;
    animation: surface-emerge 1.2s ease-out 0.2s forwards;
}

.domain-tld {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(1.5rem, 4vw, 3.5rem);
    color: var(--teal);
    letter-spacing: 0.06em;
    opacity: 0;
    animation: surface-emerge 1.2s ease-out 0.5s forwards;
}

@keyframes surface-emerge {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.surface-sub {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.85;
    color: var(--sand);
    opacity: 0.7;
    letter-spacing: 0.03em;
    margin-bottom: 2.5rem;
    font-style: italic;
}

.surface-circuit-line {
    width: min(600px, 90%);
    opacity: 0.7;
}

.circuit-line-svg {
    width: 100%;
    height: auto;
}

/* ---- Section 3: Depth ---- */
.depth-inner {
    display: flex;
    gap: 5vw;
    align-items: flex-start;
    padding: 0 8vw;
    max-width: 1100px;
    width: 100%;
}

.depth-label-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    flex-shrink: 0;
    padding-top: 0.4rem;
}

.section-label {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 0.65rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--teal);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    opacity: 0.55;
}

.section-label.light {
    color: var(--amber);
    opacity: 0.65;
}

.vert-circuit {
    width: 20px;
    height: 200px;
}

.depth-content {
    flex: 1;
}

.depth-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    color: var(--light-amber);
    letter-spacing: 0.04em;
    line-height: 1.1;
    margin-bottom: 2rem;
}

.depth-body {
    font-family: var(--font-body);
    font-size: 1.06rem;
    line-height: 1.85;
    color: var(--sand);
    opacity: 0.85;
    margin-bottom: 1.4rem;
    max-width: 58ch;
}

.depth-rule {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2.5rem;
}

.rule-dash {
    display: block;
    height: 1px;
    width: 40px;
    background: var(--teal);
    opacity: 0.4;
}

.rule-node {
    display: block;
    width: 6px;
    height: 6px;
    border: 1px solid var(--teal);
    border-radius: 50%;
    opacity: 0.5;
}

.rule-dash.long {
    width: 80px;
    opacity: 0.2;
}

/* ---- Section 4: Current ---- */
.current-bg-traces {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.current-inner {
    padding: 0 8vw;
    max-width: 1100px;
    width: 100%;
}

.current-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    color: var(--light-amber);
    letter-spacing: 0.03em;
    line-height: 1.1;
    margin: 0.8rem 0 3rem;
}

.current-heading em {
    font-style: italic;
    color: var(--teal);
}

.current-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5rem 3.5rem;
}

.current-item {
    position: relative;
    padding-left: 1.2rem;
}

.item-trace-mark {
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 1px;
    height: calc(100% - 0.5rem);
    background: linear-gradient(to bottom, var(--teal), transparent);
    opacity: 0.4;
}

.item-trace-mark::before {
    content: '';
    position: absolute;
    top: 0;
    left: -2px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--teal);
    opacity: 0.7;
}

.item-label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--amber);
    margin-bottom: 0.6rem;
}

.item-desc {
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--sand);
    opacity: 0.78;
}

/* ---- Section 5: Stillness ---- */
.stillness-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 3.5rem;
    padding: 0 8vw;
    max-width: 700px;
}

.stillness-daisy {
    width: 90px;
    height: 90px;
    animation: daisy-slow-spin 30s linear infinite;
}

@keyframes daisy-slow-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.stillness-quote {
    border: none;
}

.stillness-quote p {
    font-family: var(--font-body);
    font-size: clamp(1rem, 2.2vw, 1.28rem);
    line-height: 2;
    color: #F5EDD8;
    opacity: 0.75;
    font-style: italic;
    letter-spacing: 0.02em;
}

.stillness-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.footer-domain {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.22em;
    color: var(--teal);
    opacity: 0.55;
    text-transform: lowercase;
}

.footer-sep {
    color: var(--copper);
    opacity: 0.4;
}

.footer-glyph {
    font-size: 1.4rem;
    color: var(--amber);
    opacity: 0.5;
    letter-spacing: 0;
}

/* ---- Intersection Observer Reveal ---- */
.reveal {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.9s ease, transform 0.9s ease;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Dynamic circuit trace SVGs (appended by JS) ---- */
.bg-trace-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ---- Teal glow utilities ---- */
.teal-glow {
    text-shadow: 0 0 20px rgba(123, 196, 176, 0.4);
}

.amber-glow {
    text-shadow: 0 0 20px rgba(200, 169, 110, 0.3);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .site-nav {
        padding: 0 1.4rem;
    }

    .nav-links {
        gap: 1rem;
    }

    .nav-links a {
        font-size: 0.65rem;
    }

    .surface-inner,
    .depth-inner,
    .current-inner,
    .stillness-inner {
        padding: 0 5vw;
    }

    .depth-inner {
        flex-direction: column;
        gap: 2rem;
    }

    .depth-label-col {
        flex-direction: row;
        writing-mode: horizontal-tb;
    }

    .section-label {
        writing-mode: horizontal-tb;
        transform: none;
        text-orientation: unset;
    }

    .vert-circuit {
        display: none;
    }

    .current-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .emerge {
        clip-path: polygon(0 0, 100% 0, 100% 94%, 0 100%);
    }

    .surface {
        clip-path: polygon(0 2%, 100% 0, 100% 96%, 0 100%);
    }

    .depth,
    .current,
    .stillness {
        clip-path: polygon(0 2%, 100% 0, 100% 96%, 0 100%);
    }
}
