/*
 * shared.css — DEEPCORE NEW_UI design tokens + base layout.
 * Palette/typography mirrors the existing Phaser DOM-overlay scenes
 * (see PHASER/src/scenes/LoginScene.js etc.) so NEW_UI pages look identical
 * to the ones they replace.
 */

/* Rubik — bold, geometric, highly legible at small sizes (replaces Cinzel/Cinzel
   Decorative, which read as fancy-but-hard-to-scan for real UI copy). One family,
   different weights, used for both titles and body text. */
@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600;700;800;900&display=swap');

:root {
    --c-cream:  #ffe8a0;
    --c-amber:  #c87820;
    --c-orange: #f0883e;
    --c-blue:   #58a6ff;
    --c-green:  #3fb950;
    --c-gold:   #ffd700;
    --c-red:    #f85149;
    --c-purple: #a371f7;

    --font-title: 'Rubik', sans-serif;
    --font-body:  'Rubik', sans-serif;
    --font-mono:  'Courier New', monospace;
}

*, *::before, *::after { box-sizing: border-box; }

/* Any element with the `hidden` attribute must actually hide — without this,
   an author rule that sets `display` on the same selector (e.g. `.auth-card,
   .auth-session { display:flex }` below) wins the cascade over the browser's
   built-in `[hidden]{display:none}` UA rule, since normal-author beats
   normal-UA regardless of specificity. That was the logout-button bug: the
   session card never actually hid, so re-hiding it after logout did nothing. */
[hidden] { display: none !important; }

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;               /* pages manage their own internal scroll areas */
    background: #100a04;            /* letterbox colour around the scaled stage */
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
}

button, input { font-family: inherit; }

/* ── Loading screen ─────────────────────────────────────────────────────── */

#loading-screen {
    position: fixed; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 18px;
    background: #0a0400;
    z-index: 9999;
    transition: opacity .4s ease;
}
#loading-screen.hidden { opacity: 0; pointer-events: none; }

.loading-logo {
    font-family: var(--font-title);
    font-size: 42px;
    color: var(--c-cream);
    letter-spacing: 6px;
    text-shadow: 0 0 20px rgba(240,136,62,.4);
}
.loading-track {
    width: 240px; height: 4px; border-radius: 2px;
    background: rgba(180,100,20,.2);
    overflow: hidden;
}
.loading-bar {
    height: 100%; width: 0%;
    background: linear-gradient(90deg,#7a3000,#f0883e);
    transition: width .25s ease;
}
.loading-text {
    font-family: var(--font-mono);
    font-size: 12.5px; letter-spacing: 2px;
    color: rgba(200,130,40,.6);
}

/* ── SPA container — elastic stage with a 1440×900 MINIMUM ────────────────
 * The app always fills the window exactly (width & height both, zero
 * letterbox bars, on any monitor) while never letting the LAYOUT get more
 * cramped than a 1440×900 design. index.html's inline script computes
 * `--app-w`/`--app-h`/`--app-scale` as: scale = min(1, vw/1440, vh/900);
 * appW = vw/scale; appH = vh/scale. Because width×scale and height×scale
 * both equal the real viewport size BY CONSTRUCTION, the stage always
 * exactly fills the window on both axes — there is no aspect-ratio
 * mismatch that could leave a bar. Whichever axis is tighter relative to
 * its floor renders at EXACTLY 1440 (or 900); the other axis comes out
 * LARGER than its floor (extra breathing room for the flexible middle
 * columns) instead of ever showing an empty margin. On a screen at or
 * above 1440×900, scale caps at 1 and appW/appH just become vw/vh — the
 * stage IS the window, natively, no scaling at all.
 *
 * `container-type: inline-size` makes #app the query container for every
 * page CSS file's `@container (max-width: …)` block (they were `@media`
 * queries before the landscape-lock — see the 2026-09-11 memory note).
 * appW is ALWAYS >= 1440 by the same construction above, so none of those
 * `max-width < 1440` blocks ever fire → the desktop layout is the only
 * layout, on every device size. The transform already makes #app a
 * containing block + stacking context, so `container-type` adds no new
 * side effects for the fixed-position overlays pages append into #app.
 */
#app {
    position: fixed;
    top: 50%; left: 50%;
    width: var(--app-w, 1440px); height: var(--app-h, 900px);
    transform: translate(-50%, -50%) scale(var(--app-scale, 1));
    transform-origin: center center;
    overflow: hidden;
    container-type: inline-size;
}
#app.hidden { display: none; }
#app.page-fade-out { opacity: 0; transition: opacity .18s ease; }
#app.page-fade-in  { opacity: 1; transition: opacity .22s ease; }

/* ── Portrait rotate gate (touch devices held in portrait) ────────────
 * Primary trigger: index.html's inline script adds `html.rotate-gate-on`
 * when the device is touch-capable AND innerHeight > innerWidth. The
 * pure-CSS `@media` rule below is a fallback for real phones in case the
 * script is delayed. Shared visual styling lives in the always-on block. */
/* Sized in vw (not px): index.html pins the viewport to width=1440, so the
   browser down-scales the whole page to the physical screen — px sizes here
   would come out microscopic on a real phone; vw units stay readable. */
#rotate-gate {
    display: none;
    position: fixed; inset: 0; z-index: 100000;
    flex-direction: column; align-items: center; justify-content: center; gap: 1.6vw;
    background: #100a04; color: var(--c-cream); text-align: center; padding: 6vw;
}
#rotate-gate .rg-icon { font-size: 15vw; line-height: 1; animation: rg-rock 1.9s ease-in-out infinite; }
#rotate-gate .rg-title { font-family: var(--font-title); font-size: 5vw; font-weight: 800; letter-spacing: .5vw; }
#rotate-gate .rg-text { font-size: 3vw; line-height: 1.7; color: rgba(255,232,160,.7); max-width: 66vw; }
@keyframes rg-rock { 0%, 100% { transform: rotate(-12deg); } 55% { transform: rotate(80deg); } }

html.rotate-gate-on #app,
html.rotate-gate-on #loading-screen { display: none !important; }
html.rotate-gate-on #rotate-gate { display: flex; }

@media (orientation: portrait) and (pointer: coarse) {
    #app, #loading-screen { display: none !important; }
    #rotate-gate { display: flex; }
}

/* ── Shared auth screen (Login / Register) ─────────────────────────────── */

.auth-screen {
    position: relative;
    width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    overflow: hidden;
}
.auth-bg {
    position: absolute; inset: 0;
    background-image: url('../bg/start_bg.png');
    background-size: cover;
    background-position: center;
}
.auth-bg::after {
    content: ''; position: absolute; inset: 0;
    background: rgba(6,2,0,.55);
}

.auth-particles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.auth-particles .dot {
    position: absolute; bottom: -10px;
    width: 6px; height: 6px; border-radius: 50%;
    background: #f0883e;
    opacity: 0;
    animation-name: dc-float-up;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}
.auth-particles .dot:nth-child(3n)   { background: #ffd700; }
.auth-particles .dot:nth-child(3n+1) { background: #ff6b35; }
@keyframes dc-float-up {
    0%   { transform: translateY(0) scale(.6); opacity: 0; }
    10%  { opacity: .35; }
    90%  { opacity: .12; }
    100% { transform: translateY(-100vh) scale(1); opacity: 0; }
}

.auth-titlewrap { position: relative; z-index: 2; text-align: center; margin-bottom: 28px; padding: 0 16px; }
.auth-title {
    font-family: var(--font-title);
    font-size: 58px; font-weight: 900;
    color: var(--c-cream);
    text-shadow: 0 2px 0 #3a1800, 0 0 30px rgba(240,136,62,.4);
    margin: 0; letter-spacing: 2px;
}
.auth-subtitle {
    font-weight: 500;
    font-size: 12px; letter-spacing: 6px;
    color: rgba(200,120,40,.8);
    margin-top: 10px;
}
.auth-rule { width: 260px; max-width: 70vw; height: 1px; background: rgba(200,120,32,.35); margin: 14px auto 0; }

.auth-card, .auth-session {
    /* field_bg_input.png = the 2nd (right) sprite cropped out of
       bg/UI/Sprite sheets/field_bg.png — a plain tan panel, no "SETTINGS"
       label baked in. This replaces the old CSS-drawn box (gradient + border
       + cut-corner clip-path) with the real asset. Stretched to fill; the
       artwork is a soft, simple rounded rect so non-uniform scaling doesn't
       visibly warp it. */
    position: relative; z-index: 2;
    display: flex; flex-direction: column; gap: 14px;
    width: 450px; max-width: 110vw;
    padding: 64px;
    background-image: url('../bg/UI/Sprite sheets/field_bg_input.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

.auth-field input {
    background: rgba(10,4,0,.55);
    border: 1px solid rgba(90,50,10,.35);
    border-radius: 6px;
    color: var(--c-cream);
    padding: 13px 16px;
    font-size: 15px;
    font-weight: 500;
    outline: none;
    width: 100%;
    letter-spacing: .5px;
    transition: border-color .15s, background .15s;
}
.auth-field input::placeholder { color: rgba(255,232,160,.4); }
.auth-field input:focus        { border-color: rgba(240,136,62,.7); background: rgba(10,4,0,.75); }

.auth-error {
    color: #a3291d;                 /* darkened red — var(--c-red) washes out on the tan card */
    font-size: 12px; min-height: 16px;
    text-align: center; line-height: 1.4;
}

.auth-btn {
    /* button_default_bg.png = 1st (top-left) sprite cropped out of the
       2x2 grid in bg/UI/Sprite sheets/UI Big Play Button.png — the blank
       button shape with no baked-in label, so any button text can go on it. */
    background-image: url('../bg/UI/Sprite sheets/button_default_bg.png');
    background-color: transparent;  /* native <button> has an opaque UA background-color that shows through the sprite's transparent corners otherwise */
    background-size: 100% 100%;
    background-repeat: no-repeat;
    appearance: none;
    -webkit-appearance: none;
    border: none;
    color: #4a2f12;                 /* dark brown — matches the card/field text convention on tan art */
    padding: 14px;
    font-size: 15px; font-weight: 700;
    letter-spacing: 4px;
    cursor: pointer;
    width: 100%;
    transition: filter .15s, transform .1s;
}
.auth-btn:hover:not(:disabled)  { filter: brightness(1.08); transform: translateY(-1px); }
.auth-btn:active:not(:disabled) { filter: brightness(.95); transform: translateY(0) scale(.98); }
.auth-btn:disabled { opacity: .55; cursor: default; }

.auth-switch { text-align: center; font-size: 12px; color: #6b4520; }
.auth-link   { color: #8a3d00; cursor: pointer; text-decoration: underline; font-weight: 600; }

.auth-session-text { text-align: center; color: #3a2410; font-size: 13px; line-height: 1.6; }
.auth-success       { text-align: center; color: #2b6b3a; font-size: 13px; line-height: 1.6; }

.auth-version {
    position: absolute; right: 14px; bottom: 10px;
    font-size: 11.5px; color: #3a2008;
    z-index: 2;
}
