/* estuardoenriquez.com v2 — "A Day at Lake Atitlán"
   Two render modes:
   - default / .fallback : normal document flow over a static CSS dawn scene
   - .xp                 : WebGL experience; sections become fixed overlays driven by JS (--p) */

:root {
    --ink: #3a2d52;             /* JS interpolates this across the day in .xp mode */
    --ink-soft: color-mix(in srgb, var(--ink) 72%, transparent);
    --hair: color-mix(in srgb, var(--ink) 28%, transparent);
    --glass: rgba(255, 255, 255, 0.16);
    --serif: "Instrument Serif", Georgia, serif;
    --sans: "Space Grotesk", system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }
html.xp { overflow: hidden; }

body {
    font-family: var(--sans);
    color: var(--ink);
    background: #c9b8d8;
    -webkit-font-smoothing: antialiased;
}

::selection { background: #4aaedb; color: #fff; }

/* ---------- layers ---------- */

#gl { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: none; }
.xp #gl { display: block; }

#grain {
    position: fixed; inset: -60px; z-index: 5; pointer-events: none; opacity: 0.06;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
    animation: grain 0.7s steps(6) infinite;
}
@keyframes grain {
    0% { transform: translate(0, 0); }       20% { transform: translate(-18px, 12px); }
    40% { transform: translate(12px, -20px); } 60% { transform: translate(-24px, -8px); }
    80% { transform: translate(20px, 16px); }  100% { transform: translate(0, 0); }
}
@media (prefers-reduced-motion: reduce) { #grain { animation: none; } }

/* ---------- static scene (no-JS, fallback, and pre-boot) ---------- */

#fallback-scene { position: fixed; inset: 0; z-index: 0; }
.xp #fallback-scene { display: none; }

.fs-sky {
    position: absolute; inset: 0;
    background: linear-gradient(#a998c9 0%, #c9b8d8 38%, #f4d5e0 68%, #f9e3e6 72%);
}
.fs-volcano { position: absolute; bottom: 28%; }
.fs-v1 {   /* San Pedro — left, sharp */
    left: -6%; width: 44%; height: 34vh; background: #8f7bb0;
    clip-path: polygon(0 100%, 38% 8%, 46% 14%, 58% 0, 100% 100%);
    opacity: 0.85;
}
.fs-v2 {   /* Tolimán — center, broad */
    left: 30%; width: 52%; height: 26vh; background: #a58fc2;
    clip-path: polygon(0 100%, 30% 12%, 50% 2%, 68% 16%, 100% 100%);
    opacity: 0.7;
}
.fs-v3 {   /* Atitlán — right, tall */
    right: -8%; width: 46%; height: 40vh; background: #7a659c;
    clip-path: polygon(0 100%, 42% 6%, 52% 0, 62% 10%, 100% 100%);
    opacity: 0.92;
}
.fs-water {
    position: absolute; left: 0; right: 0; bottom: 0; height: 28%;
    background: linear-gradient(#e9d3e4 0%, #c5b0d4 30%, #a189b8 100%);
    box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.45);
}

/* ---------- chrome ---------- */

#top-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 3;
    display: flex; justify-content: space-between; align-items: center;
    padding: 22px clamp(20px, 4vw, 48px);
}
.wordmark {
    font-size: 0.82rem; font-weight: 500; letter-spacing: 0.22em;
    color: var(--ink); text-decoration: none;
}
#audio-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    background: none; border: 1px solid var(--hair); border-radius: 999px;
    color: var(--ink); padding: 7px 14px; cursor: pointer;
    font-family: var(--sans); font-size: 0.68rem; letter-spacing: 0.28em; text-transform: uppercase;
    transition: border-color 0.3s;
}
#audio-toggle[hidden] { display: none; }
#audio-toggle:hover { border-color: var(--ink); }
#audio-toggle[aria-pressed="true"] .wave { stroke: #4aaedb; }

#dots {
    position: fixed; right: clamp(14px, 2.5vw, 30px); top: 50%; transform: translateY(-50%);
    z-index: 3; display: flex; flex-direction: column; gap: 14px;
}
#dots[hidden] { display: none; }
#dots button {
    width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--ink-soft);
    background: transparent; cursor: pointer; padding: 0; transition: background 0.3s, transform 0.3s;
}
#dots button.on { background: var(--ink); transform: scale(1.3); }

/* ---------- sections: flow mode (default) ---------- */

#content { position: relative; z-index: 2; }

#content section {
    min-height: 100svh;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    text-align: center; padding: 96px clamp(20px, 5vw, 56px);
    position: relative;
}
.inner { max-width: 1080px; width: 100%; }
.inner.narrow { max-width: 680px; }

/* xp mode: sections become fixed overlay slides; JS drives opacity/transform per frame */
.xp #content section {
    position: fixed; inset: 0; min-height: 100dvh;
    opacity: 0; pointer-events: none;
    will-change: opacity, transform;
}
.xp #content section.live a,
.xp #content section.live button { pointer-events: auto; }
.xp #content .inner { text-shadow: 0 0 26px var(--halo, rgba(255,255,255,0.4)), 0 0 3px var(--halo, rgba(255,255,255,0.4)); }

/* ---------- type ---------- */

.label {
    font-size: 0.66rem; font-weight: 500; letter-spacing: 0.42em; text-transform: uppercase;
    color: var(--ink-soft); margin-bottom: clamp(18px, 3vh, 34px);
}

h1 { line-height: 0.92; font-weight: 400; }
.name-serif {
    display: block; font-family: var(--serif); font-style: italic; font-weight: 400;
    font-size: clamp(2.6rem, 7.5vw, 6.4rem); letter-spacing: 0.01em;
}
.name-sans {
    display: block; font-family: var(--sans); font-weight: 700;
    font-size: clamp(3.1rem, 11.5vw, 10rem); letter-spacing: -0.015em; margin-top: 0.04em;
}
.hero-line {
    font-family: var(--serif); font-style: italic;
    font-size: clamp(1.15rem, 2.3vw, 1.75rem); margin-top: clamp(20px, 3.5vh, 40px);
    color: var(--ink-soft);
}
/* faja: the woven-belt stripe — Guatemalan textile colors */
:root {
    --tejido: repeating-linear-gradient(90deg,
        #d5286a 0 26px, #f2a413 26px 46px, #1f7ec2 46px 70px,
        #2ea86b 70px 88px, #e04729 88px 108px, #7b3fa0 108px 126px);
}
.faja {
    height: 6px;
    width: min(320px, 42vw);
    margin: clamp(22px, 4vh, 42px) auto 0;
    border-radius: 3px;
    background: var(--tejido);
    background-size: 126px 100%;
}

.scroll-hint {
    position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
    font-size: 0.64rem; letter-spacing: 0.34em; text-transform: uppercase; color: var(--ink-soft);
    display: flex; align-items: center; gap: 10px; white-space: nowrap;
}
.scroll-hint .chev { animation: chev 2.2s ease-in-out infinite; }
@keyframes chev { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }
.fallback .scroll-hint, .scroll-hint:only-child { display: none; }
@media (prefers-reduced-motion: reduce) { .scroll-hint .chev { animation: none; } }

.prose {
    font-size: clamp(1.1rem, 1.9vw, 1.4rem); line-height: 1.75; font-weight: 400;
    text-wrap: pretty;
}
.prose .em { font-family: var(--serif); font-style: italic; }

/* ---------- project cards ---------- */

.cards {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(14px, 2vw, 26px);
    text-align: left;
}
.card {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; gap: 12px;
    padding: clamp(22px, 2.6vw, 34px);
    background: var(--glass);
    border: 1px solid var(--hair);
    border-radius: 18px;
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    color: var(--ink); text-decoration: none;
    transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.45s;
}
.card::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: var(--tejido); background-size: 126px 100%;
    opacity: 0.55; transition: opacity 0.4s;
}
.card:hover { transform: translateY(-6px); border-color: var(--ink-soft); }
.card:hover::after { opacity: 1; }
.card h2 { font-size: clamp(1.25rem, 2vw, 1.7rem); font-weight: 700; letter-spacing: 0.01em; line-height: 1.1; }
.card .c-serif { font-family: var(--serif); font-style: italic; font-weight: 400; display: block; font-size: 0.82em; }
.card p { font-size: 0.92rem; line-height: 1.55; color: var(--ink-soft); flex: 1; }
.card .visit { font-size: 0.68rem; letter-spacing: 0.3em; text-transform: uppercase; font-weight: 500; }
.card .visit .arr { display: inline-block; transition: transform 0.3s; }
.card:hover .visit .arr { transform: translateX(5px); }

/* ---------- contact ---------- */

.email {
    display: inline-block; color: var(--ink); text-decoration: none;
    font-size: clamp(1.35rem, 3.6vw, 2.7rem); font-weight: 500; letter-spacing: -0.01em;
    border-bottom: 3px solid transparent;
    border-image: repeating-linear-gradient(90deg,
        #d5286a 0 26px, #f2a413 26px 46px, #1f7ec2 46px 70px,
        #2ea86b 70px 88px, #e04729 88px 108px, #7b3fa0 108px 126px) 1;
    padding-bottom: 6px;
    transition: filter 0.3s;
}
.email:hover { filter: brightness(1.15); }
.email .e-serif { font-family: var(--serif); font-style: italic; font-weight: 400; }
.contact-line { margin-top: 22px; font-family: var(--serif); font-style: italic; font-size: 1.1rem; color: var(--ink-soft); }
.skills { margin-top: clamp(30px, 5vh, 54px); font-size: 0.72rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--ink-soft); }
.colophon { margin-top: clamp(36px, 7vh, 70px); font-size: 0.68rem; letter-spacing: 0.06em; color: var(--ink-soft); }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
    .cards { grid-template-columns: 1fr; gap: 12px; }
    .card { flex-direction: column; padding: 16px 20px; gap: 8px; }
    .card h2 { font-size: 1.15rem; }
    .card .c-serif { display: inline; font-size: 0.9em; margin-right: 6px; }
    .card p { font-size: 0.84rem; line-height: 1.45; }
    #dots { right: 10px; }
    #content section { padding: 72px 20px; }
}
