/* ==========================================================================
   Sunrise Story — shared styles (home + press kit)
   Tokens, type, header, buttons, frames, chapters, footer, lightbox.
   ========================================================================== */

:root {
    /* Colour, sampled from the game's own artwork */
    --ink: #14324f;
    --ink-soft: #3f5f7d;
    --paper: #fffaf3;
    --sand: #fef1e1;
    --sand-deep: #fee8cc;
    --sun: #ffc83d;
    --sun-deep: #f29a1f;
    --ember: #c2410c;
    --sky: #56aff7;
    --sky-pale: #7ecdfd;
    --sea: #0f6cbd;
    --sea-deep: #0b4f96;
    --sea-night: #0a4283;
    --grass: #c5e8a6;
    --grass-deep: #a9db86;
    --leaf: #2f6b2f;
    --dusk-top: #3b4a8c;
    --dusk: #24526f;

    /* Type */
    --font-display: "Baloo 2", "Nunito", "Trebuchet MS", system-ui, sans-serif;
    --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-hand: "Patrick Hand", "Baloo 2", "Comic Sans MS", cursive;

    --text-sm: 0.9375rem;
    --text-base: 1.0625rem;
    --text-lg: 1.1875rem;
    --text-h3: clamp(1.5rem, 1.25rem + 1vw, 2rem);
    --text-h2: clamp(2rem, 1.35rem + 2.8vw, 3.25rem);

    /* Shape */
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --line: 3px;
    --lift: 6px;

    /* Layout */
    --container: 1180px;
    --gutter: clamp(18px, 4vw, 40px);
    --section-pad: clamp(64px, 8vw, 120px);
    --header-h: 68px;
    --edge-h: clamp(40px, 5.5vw, 76px);

    --focus: var(--ink);

    /* Repeating edge shapes, used as masks so each chapter can colour its own edge */
    --shape-wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 480 80' preserveAspectRatio='none'%3E%3Cpath d='M0 64C80 64 160 16 240 16S400 64 480 64V80H0Z'/%3E%3C/svg%3E");
    --shape-wave-offset: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 480 80' preserveAspectRatio='none'%3E%3Cpath d='M0 14C80 14 160 58 240 58S400 14 480 14V80H0Z'/%3E%3C/svg%3E");
    --shape-ripple: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 20' preserveAspectRatio='none'%3E%3Cpath d='M0 0H120V8C105 8 105 20 90 20S75 8 60 8 45 20 30 20 15 8 0 8Z'/%3E%3C/svg%3E");
    --shape-grass: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 40' preserveAspectRatio='none'%3E%3Cpath d='M0 40V22Q12 2 24 22Q36 6 48 22Q60 -2 72 22Q84 8 96 22V40Z'/%3E%3C/svg%3E");
    --shape-hills: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 80' preserveAspectRatio='none'%3E%3Cpath d='M0 52C200 4 420 4 640 40S1120 80 1440 22V80H0Z'/%3E%3C/svg%3E");
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--sand);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
}
img, svg, video, iframe { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
[id] { scroll-margin-top: calc(var(--header-h) + 40px); }

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
    border-radius: 6px;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 800;
    line-height: 1.12;
    text-wrap: balance;
}
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); }
p { text-wrap: pretty; }

.container {
    width: min(100% - var(--gutter) * 2, var(--container));
    margin-inline: auto;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    padding: 10px 16px;
    background: var(--sun);
    color: var(--ink);
    border: var(--line) solid var(--ink);
    border-radius: var(--radius-sm);
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* ---------- Icons ---------- */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
    width: 1.15em;
    height: 1.15em;
    flex: none;
    fill: currentColor;
}

/* ---------- Header ---------- */
.site-header {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 50;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding-inline: clamp(16px, 4vw, 44px);
    background: var(--paper);
    filter: drop-shadow(0 4px 0 rgba(20, 50, 79, 0.16));
}
/* The rippled lower edge of the header */
.site-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% - 1px);
    height: 16px;
    background: var(--paper);
    -webkit-mask: var(--shape-ripple) repeat-x left top / 96px 100%;
    mask: var(--shape-ripple) repeat-x left top / 96px 100%;
    pointer-events: none;
}
.brand { display: block; flex: none; border-radius: 8px; }
.brand-logo {
    display: block;
    width: 146px;
    aspect-ratio: 516 / 196;
    background: url("../images/branding/game-logo-ink.png") center / contain no-repeat;
    transition: transform 0.2s ease;
}
.brand:hover .brand-logo { transform: rotate(-2deg) scale(1.04); }

.site-nav {
    display: flex;
    align-items: center;
    gap: clamp(2px, 0.8vw, 10px);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.0625rem;
}
.site-nav > a:not(.btn) {
    padding: 6px 12px;
    border-radius: 999px;
    text-decoration: none;
    line-height: 1.3;
    transition: background-color 0.15s ease;
}
.site-nav > a:not(.btn):hover { background: var(--sand-deep); }
.site-nav > a.is-current { background: var(--sun); }
.nav-cta { margin-left: 8px; }

.menu-toggle {
    display: none;
    width: 46px;
    height: 46px;
    place-items: center;
    background: var(--sun);
    border: var(--line) solid var(--ink);
    border-radius: 14px;
    box-shadow: 0 4px 0 var(--ink);
}
.menu-toggle .icon { width: 20px; height: 20px; }
.menu-toggle .icon-close,
.menu-toggle[aria-expanded="true"] .icon-open { display: none; }
.menu-toggle[aria-expanded="true"] .icon-close { display: block; }

@media (max-width: 1099px) {
    .menu-toggle { display: grid; }
    .site-nav {
        position: absolute;
        top: calc(100% + 22px);
        left: 12px;
        right: 12px;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: 14px;
        background: var(--paper);
        border: var(--line) solid var(--ink);
        border-radius: var(--radius-lg);
        box-shadow: 0 var(--lift) 0 var(--ink);
        font-size: 1.25rem;
        visibility: hidden;
        opacity: 0;
        transform: translateY(-10px);
        transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s 0.18s;
    }
    .site-nav.active {
        visibility: visible;
        opacity: 1;
        transform: none;
        transition: opacity 0.18s ease, transform 0.18s ease;
    }
    .site-nav > a:not(.btn) { padding: 10px 16px; border-radius: 12px; }
    .nav-cta { margin: 10px 0 4px; justify-content: center; }
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55em;
    padding: 0.6em 1.25em;
    background: var(--sun);
    color: var(--ink);
    border: var(--line) solid var(--ink);
    border-radius: var(--radius-md);
    box-shadow: 0 5px 0 var(--ink);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.125rem;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); background: #ffd65f; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.btn--small { font-size: 1rem; padding: 0.4em 1em; border-radius: 13px; box-shadow: 0 4px 0 var(--ink); }
.btn--small:hover { box-shadow: 0 6px 0 var(--ink); }
.btn--large { font-size: clamp(1.125rem, 1rem + 0.5vw, 1.3125rem); padding: 0.68em 1.4em; }
.btn--paper { background: var(--paper); }
.btn--paper:hover { background: #fff; }
.btn--ghost {
    background: transparent;
    color: #fff;
    border-color: #fff;
    box-shadow: 0 5px 0 rgba(255, 255, 255, 0.35);
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.12); box-shadow: 0 7px 0 rgba(255, 255, 255, 0.35); }
.btn--ghost:active { box-shadow: 0 2px 0 rgba(255, 255, 255, 0.35); }

/* ---------- Frames: the outlined "sticker" treatment for imagery ---------- */
.frame {
    border: var(--line) solid var(--ink);
    border-radius: var(--radius-lg);
    box-shadow: 0 var(--lift) 0 var(--ink);
    background: var(--paper);
    overflow: hidden;
}
.frame--light {
    border: 5px solid #fff;
    box-shadow: 0 9px 0 rgba(4, 30, 70, 0.5);
    background: #fff;
}

/* ---------- Chapters: full-width colour worlds with shaped top edges ---------- */
.chapter { position: relative; overflow-x: clip; }
.chapter + .chapter { margin-top: calc(var(--edge-h) * -1); }
.chapter-body {
    position: relative;
    padding-bottom: var(--edge-h);
    color: var(--chapter-ink, var(--ink));
}
.edge {
    position: relative;
    z-index: 2;
    height: var(--edge-h);
    margin-bottom: -1px;
    overflow: hidden;
    pointer-events: none;
}
.edge-front, .edge-back {
    position: absolute;
    inset: 0;
    background: var(--edge-color);
    -webkit-mask: var(--edge-shape) repeat-x left bottom / var(--edge-tile, 480px) 100%;
    mask: var(--edge-shape) repeat-x left bottom / var(--edge-tile, 480px) 100%;
}

.section { padding-block: var(--section-pad); }
.section + .section { padding-top: 0; }
.section-head {
    max-width: 44rem;
    margin: 0 auto clamp(32px, 5vw, 56px);
    text-align: center;
}
.section-head p {
    margin-top: 14px;
    font-size: var(--text-lg);
    color: var(--chapter-ink-soft, var(--ink-soft));
}
.section-head--left { margin-inline: 0; text-align: left; }

.chapter--sand .chapter-body {
    background: var(--sand) url("../images/backgrounds/pattern.png") center top / 256px;
}
.chapter--sea {
    --chapter-ink: #fff;
    --chapter-ink-soft: rgba(255, 255, 255, 0.9);
    --focus: var(--sun);
}
.chapter--sea .chapter-body {
    background: linear-gradient(180deg, var(--sea) 0%, var(--sea-deep) 55%, var(--sea-night) 100%);
}

/* Edge variants shared by both pages */
.edge--sea { --edge-shape: var(--shape-wave); --edge-color: var(--sea); }
.edge--sea .edge-back {
    --edge-shape: var(--shape-wave-offset);
    --edge-color: var(--sky-pale);
    right: -480px;
    animation: wave-drift 16s linear infinite;
}
@keyframes wave-drift { to { transform: translateX(-480px); } }
.edge--beach { --edge-shape: var(--shape-wave); --edge-color: var(--sand); --edge-tile: 620px; }
.edge--beach .edge-back { --edge-color: #fff; transform: translateY(-9px); opacity: 0.92; }

/* ---------- Footer ---------- */
.footer {
    --focus: var(--sun);
    position: relative;
    background: var(--dusk);
    color: #fff;
    padding: 8px 0 36px;
}
.footer-inner {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1.2fr;
    gap: 40px;
    padding-top: 44px;
    border-top: 2px dashed rgba(255, 255, 255, 0.25);
}
.footer-game-name {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2rem;
    line-height: 1.1;
}
.footer-game-name span { color: var(--sun); }
.footer-tagline { margin-top: 6px; color: rgba(255, 255, 255, 0.85); }
.footer-studio { width: 150px; margin-top: 22px; border-radius: 4px; }
.footer-label {
    margin-bottom: 12px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--sun);
}
.footer-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; align-content: start; }
.footer-nav .footer-label { grid-column: 1 / -1; margin-bottom: 6px; }
.footer-nav a { text-decoration: none; padding: 2px 0; width: fit-content; }
.footer-nav a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.social-links { display: flex; flex-wrap: wrap; gap: 10px; }
.social-links a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.social-links a:hover { background: #fff; border-color: #fff; color: var(--dusk); }
.social-links--ink a { border-color: var(--ink); }
.social-links--ink a:hover { background: var(--sun); border-color: var(--ink); color: var(--ink); }
.footer-copyright {
    margin-top: 36px;
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.8);
}

@media (max-width: 820px) {
    .footer-inner { grid-template-columns: 1fr; gap: 32px; }
}

/* ---------- Screenshot tiles + lightbox (home gallery and press kit) ---------- */
.gallery-item {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    cursor: zoom-in;
    text-decoration: none;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-item:hover,
.gallery-item:focus-visible { transform: translateY(-4px); box-shadow: 0 10px 0 var(--ink); }
.gallery-item:focus-visible { border-radius: var(--radius-lg); }
.gallery-caption {
    position: absolute;
    left: 10px;
    bottom: 10px;
    max-width: calc(100% - 20px);
    padding: 3px 10px;
    background: var(--paper);
    color: var(--ink);
    border: 2px solid var(--ink);
    border-radius: 9px;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
}

dialog#imageModal {
    --focus: var(--sun);
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(8, 28, 52, 0.94);
    color: #fff;
}
dialog#imageModal::backdrop { background: rgba(8, 28, 52, 0.94); }
.dialog-content {
    position: relative;
    display: grid;
    grid-template-rows: 1fr auto;
    place-items: center;
    gap: 14px;
    width: 100%;
    height: 100%;
    padding: 64px clamp(12px, 6vw, 88px) 24px;
}
#fullImage {
    max-width: 100%;
    max-height: 100%;
    min-height: 0;
    object-fit: contain;
    border: 4px solid #fff;
    border-radius: 14px;
    background: var(--sea-night);
}
.dialog-caption { font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; text-align: center; }
.dialog-close, .dialog-nav-btn {
    position: absolute;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    background: var(--paper);
    color: var(--ink);
    border: var(--line) solid var(--ink);
    border-radius: 50%;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45);
}
.dialog-close:hover, .dialog-nav-btn:hover { background: var(--sun); }
.dialog-close { top: 12px; right: 14px; }
.dialog-nav-btn { top: 50%; transform: translateY(-50%); }
.dialog-nav-btn.prev { left: clamp(6px, 1.5vw, 22px); }
.dialog-nav-btn.next { right: clamp(6px, 1.5vw, 22px); }

@media (max-width: 640px) {
    .dialog-content { padding: 64px 10px 84px; }
    .dialog-nav-btn { top: auto; bottom: 18px; transform: none; }
    .dialog-nav-btn.prev { left: calc(50% - 58px); }
    .dialog-nav-btn.next { right: calc(50% - 58px); }
    .dialog-caption { position: absolute; top: 20px; left: 14px; right: 72px; text-align: left; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-delay: 0s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
