/* Self-hosted fonts, SIL OFL 1.1 (ADR 0016). Licenses next to the files; credits in public/fonts/CREDITS.md. */
@font-face {
    font-family: 'Londrina Solid';
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    src: url('fonts/LondrinaSolid-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Londrina Solid';
    font-weight: 900;
    font-style: normal;
    font-display: swap;
    src: url('fonts/LondrinaSolid-900.woff2') format('woff2');
}
@font-face {
    font-family: 'Gaegu';
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    src: url('fonts/Gaegu-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Gaegu';
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    src: url('fonts/Gaegu-700.woff2') format('woff2');
}
/* Gaegu has no accents: this alias lends Londrina Solid's, only for those glyphs and shrunk to Gaegu's size (F12.R M2). */
@font-face {
    font-family: 'Londrina Acentos';
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    src: url('fonts/LondrinaSolid-400.woff2') format('woff2');
    unicode-range: U+00A1, U+00BF, U+00C0-00FF;
    size-adjust: 88%;
}
@font-face {
    font-family: 'Londrina Acentos';
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    src: url('fonts/LondrinaSolid-400.woff2') format('woff2');
    unicode-range: U+00A1, U+00BF, U+00C0-00FF;
    size-adjust: 88%;
}

/* Lagatovino tokens (ADR 0023): copied from lagatovino.com, not linked. Same values as Ink in constants.ts (art-direction v2). */
:root {
    --background: #FFFCF5;
    --foreground: #1F1B1A;
    --muted-foreground: #6A5F57;
    --border: #E8E0D2;
    --sol: #F3C04A;
    --frambuesa: #C2306B;
    --linea-lapiz: #8FA8E3;
    --ring: #3A5FC4;
    --font-display: 'Londrina Solid', 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
    --font-hand: 'Gaegu', 'Londrina Acentos', 'Comic Sans MS', 'Chalkboard SE', cursive;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    color: #1F1B1A;
    background-color: #FFFCF5;
    font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    /* ADR 0014: a finger must never scroll, zoom, select or open a menu over the game. */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* The page is a column: header, the stage that takes what is left, footer. */
#page {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    box-sizing: border-box;
    /* Notches and rounded corners (viewport-fit=cover). */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#stage {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-color: #FFFCF5;
}

#game-container {
    width: 100%;
    height: 100%;
}

#game-container, #game-container canvas {
    touch-action: none;
    -webkit-touch-callout: none;
    outline: none;
}

a:focus-visible, button:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

/* Header: lagatovino.com's, lighter (bottom border, wordmark on the left, pill buttons on the right). */
.site-header {
    flex: none;
    z-index: 30;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 252, 245, 0.95);
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 56px;
    padding: 0 16px;
    box-sizing: border-box;
}

.brand {
    display: inline-flex;
    flex: none;
    align-items: center;
    color: var(--foreground);
}

.brand img {
    display: block;
    height: 24px;
    width: auto;
}

.site-title {
    flex: 1 1 auto;
    margin: 0;
    font-family: var(--font-display);
    font-size: 20px;
    letter-spacing: 0.02em;
    color: var(--muted-foreground);
    white-space: nowrap;
}

.spark {
    color: var(--sol);
}

.site-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 8px;
}

/* Pill buttons: the main one is black with cream text, the other has a border (lagatovino.com). */
.pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 14px;
    border: 1.5px solid var(--foreground);
    border-radius: 9999px;
    font-family: var(--font-display);
    font-size: 18px;
    line-height: 1;
    letter-spacing: 0.02em;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.pill:hover {
    transform: rotate(-2deg);
}

.pill:active {
    transform: scale(0.96);
}

.pill-solid {
    background: var(--foreground);
    color: var(--background);
}

.pill-outline {
    background: transparent;
    color: var(--foreground);
}

.pill-outline:hover {
    background: var(--sol);
}

.pill-icon {
    width: 16px;
    height: 16px;
    flex: none;
}

.pill[hidden] {
    display: none;
}

/* Only in fullscreen: the way out, lying on the stage's top left corner, which no scene uses (F20.R M8). The header and the footer are not part of it. */
.stage-exit {
    display: none;
    position: absolute;
    left: 10px;
    top: 10px;
    z-index: 5;
    opacity: 0.55;
}

.stage-exit:hover,
.stage-exit:focus-visible {
    opacity: 1;
}

html.page-fullscreen .stage-exit:not([hidden]) {
    display: inline-flex;
}

/* Footer: the striped strip and a line of text, like the footer of lagatovino.com. */
.site-footer {
    flex: none;
    z-index: 30;
    border-top: 1px solid var(--border);
}

.stripes {
    height: 10px;
    border-bottom: 1px solid var(--border);
    background-color: var(--background);
    background-image: repeating-linear-gradient(90deg, transparent 0 2.75rem, var(--linea-lapiz) 2.75rem calc(2.75rem + 1.5px));
}

.site-footer-inner {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 12px;
    margin: 0;
    padding: 6px 16px 8px;
    font-size: 14px;
    color: var(--muted-foreground);
}

.site-footer .hand {
    font-family: var(--font-hand);
    font-size: 22px;
    font-weight: 700;
    color: var(--frambuesa);
}

.site-footer a {
    color: var(--foreground);
    text-decoration: underline;
    text-decoration-color: var(--sol);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

.site-footer a:hover {
    color: var(--muted-foreground);
}

/* Narrow windows: the wordmark and the buttons are enough. */
@media (max-width: 720px) {
    .site-title { display: none; }
    .site-actions { margin-left: auto; }
}

/* Low desktop windows (1280 x 720 is the main size, ADR 0008): the footer is one thin line, so the canvas keeps more height (F20.R M2). */
@media (max-height: 800px) {
    .stripes { display: none; }
    .site-footer-inner { padding: 3px 16px 4px; font-size: 13px; }
    .site-footer .hand { font-size: 18px; }
}

/* Little height (a phone held sideways, ADR 0014): a thin strip, no footer, so the canvas keeps its size. */
@media (max-height: 520px) {
    .site-header-inner { height: 36px; padding: 0 10px; }
    .brand img { height: 16px; }
    .site-title, .pill-text { display: none; }
    .site-actions { margin-left: auto; gap: 6px; }
    .pill { padding: 0; width: 30px; height: 30px; justify-content: center; font-size: 16px; }
    /* The hit area is a bit bigger than the drawing. */
    .pill::after { content: ''; position: absolute; inset: -4px; }
    .site-footer { display: none; }
    /* The way out in fullscreen keeps its word: it is the only thing on the stage. */
    .stage-exit { width: auto; padding: 0 16px 0 12px; }
    .stage-exit .pill-text { display: inline; }
}

/* A phone held sideways (F20.R A1, ADR 0023 s7): the phone is longer than 16:9, so the header becomes a rail on the left and the
   canvas keeps the whole height. The buttons are 44 x 44, the touch minimum (ADR 0014). */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
    #page { flex-direction: row; }
    .site-header {
        flex: none;
        width: 56px;
        border-bottom: 0;
        border-right: 1px solid var(--border);
    }
    .site-header-inner {
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        height: 100%;
        padding: 10px 0;
        gap: 8px;
    }
    /* The wordmark is too wide for the rail: the little cat of the favicon stands for it. */
    .brand { width: 32px; height: 32px; background: url('/favicon.svg') center / contain no-repeat; }
    .brand img { display: none; }
    .site-actions { flex-direction: column; margin: 0; gap: 8px; }
    .pill { width: 44px; height: 44px; font-size: 20px; }
    .pill::after { inset: 0; }
    .pill-icon { width: 20px; height: 20px; }
}

/* Fullscreen on the stage hides the page by itself; this is for browsers that fullscreen the whole document. */
html.page-fullscreen .site-header,
html.page-fullscreen .site-footer {
    display: none;
}

/* "Gira tu teléfono": a phone held in portrait (class set by systems/touchEnv.ts). */
#rotate-hint {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: #FFFCF5;
}

html.rotate-hint #rotate-hint {
    display: flex;
}

.rotate-card {
    padding: 28px 32px;
    max-width: 80vw;
    border: 3px solid #E8E0D2;
    border-radius: 36px;
    background: #FFFFFF;
    box-shadow: 0 10px 0 #F4EEE3;
}

.rotate-phone {
    animation: rotate-wobble 2.4s ease-in-out infinite;
}

.rotate-title {
    margin: 8px 0 4px;
    font-size: 32px;
    color: #1F1B1A;
    font-family: 'Londrina Solid', sans-serif;
    font-weight: 900;
}

.rotate-text {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

@keyframes rotate-wobble {
    0%, 20% { transform: rotate(0deg); }
    55%, 80% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
    .rotate-phone {
        animation: none;
        transform: rotate(-90deg);
    }
}
