/* Charlatan Games brand layer.
   The base palette already lives in app.css :root (black & gold). This file only adds
   layout chrome (topbar, hero, game cards, game pages) plus a couple of brand-only tweaks
   under [data-theme="brand"]. */

[data-theme="brand"] {
    background: var(--bg-base);
    color: var(--text-primary);
    color-scheme: dark;
    --font-display: 'Cinzel', Georgia, 'Times New Roman', serif;
    --font-prose:   'Cormorant Garamond', Georgia, 'Times New Roman', serif;
}

/* Display moments inside brand-themed pages: wordmark, hero title, page H1, CTA pill. */
[data-theme="brand"] h1,
[data-theme="brand"] h2 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Layout chrome. Scope to [data-theme="brand"] so the rule doesn't collide with
   MainLayout's <a class="brand"> wordmark — which would otherwise inherit a 100vh
   flex column and crush the admin login form below the fold. */
[data-theme="brand"].brand {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.brand-container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 1.25rem;
}

.brand-topbar {
    background: linear-gradient(180deg, #1f1f1f 0%, #0a0a0a 100%);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 0;
    position: sticky;
    top: 0;
    z-index: 50;
}
.brand-topbar .brand-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand-mark {
    color: var(--amber) !important;
    font-family: var(--font-display, 'Cinzel', Georgia, serif);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.06em;
    text-decoration: none;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}
.brand-mark:hover { color: var(--accent-hover) !important; }
.brand-nav {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Headline CTA in the topbar — gold-bordered pill that fills in on hover.
   Sits next to (but distinctly from) the Charlatan wordmark on the left. */
.brand-nav-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1.1rem;
    border-radius: 999px;
    border: 1px solid var(--accent);
    color: var(--accent);
    background: transparent;
    text-decoration: none;
    font-family: var(--font-display, 'Cinzel', Georgia, serif);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.brand-nav-cta:hover {
    background: var(--accent);
    color: #0a0a0a;
    box-shadow: 0 0 0 3px rgba(212, 161, 60, 0.22);
}

.brand-main {
    flex: 1;
    padding: 1rem 0 3rem;
}

.brand-footer {
    background: #0f0f0f;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    padding: 1rem 0;
    margin-top: auto;
    font-size: 0.9rem;
}
.brand-footer .brand-container {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.brand-footer a { color: var(--text-muted); text-decoration: none; }
.brand-footer a:hover { color: var(--accent); }

/* Charlatan landing page (BrandHome) */
.cg-hero {
    position: relative;
    height: 50vh;
    min-height: 280px;
    background-image: url('/brand/img/tree.jpg');
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.cg-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
}
.cg-hero-content {
    position: relative;
    z-index: 2;
}
.cg-hero-logo {
    max-width: 70%;
    max-height: 50vh;
    width: auto;
    height: auto;
    object-fit: contain;
    animation:
        flicker 4s infinite alternate,
        drift 12s infinite ease-in-out,
        wobble 4s infinite ease-in-out,
        glitch 1.5s infinite;
}
.cg-hero-tagline {
    color: var(--text-primary);
    margin-top: 0.75rem;
    font-family: var(--font-prose, Georgia, serif);
    font-style: italic;
    font-size: 1.35rem;
    letter-spacing: 0.02em;
}

@keyframes flicker {
    0%, 18%, 22%, 25%, 53%, 57%, 100% { opacity: 0.6; }
    20%, 24%, 55% { opacity: 0.3; }
}
@keyframes drift {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(8px, -6px); }
}
@keyframes wobble {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(1deg) skewX(1deg); }
    50% { transform: rotate(-1deg) skewY(1deg); }
    75% { transform: rotate(1deg) skewX(-1deg); }
}
@keyframes glitch {
    0% { text-shadow: 2px 0 #d4a13c; }
    20% { text-shadow: -2px 0 #b8862a; }
    40% { text-shadow: 2px 2px #f0c060; }
    60% { text-shadow: -2px -2px #8a6820; }
    80% { text-shadow: 2px -2px #e8b85a; }
    100% { text-shadow: 0 0 #fff; }
}

.cg-blurb {
    text-align: center;
    padding: 3rem 1.25rem;
    max-width: 820px;
    margin: 0 auto;
    font-family: var(--font-prose, Georgia, serif);
    font-size: 1.35rem;
    line-height: 1.5;
    color: var(--text-primary);
}
.cg-blurb strong { color: var(--accent); font-weight: 600; }
.cg-blurb .small {
    color: var(--text-muted);
    font-size: 1.2rem;
    font-style: italic;
    margin: 0.35rem 0;
}

.cg-game-grid {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 1.25rem 3rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    text-align: center;
}
.cg-game-card a {
    color: var(--text-primary);
    text-decoration: none;
    display: block;
}
.cg-game-card a:hover h2 { color: var(--accent); }
.cg-game-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    transition: border-color 120ms ease;
}
.cg-game-card a:hover img { border-color: var(--accent); }
.cg-game-card h2 {
    font-family: var(--font-display, 'Cinzel', Georgia, serif);
    font-weight: 600;
    font-size: 1.25rem;
    letter-spacing: 0.05em;
    margin: 0.4rem 0 0.4rem;
    border: none;
    padding: 0;
    color: var(--text-primary);
    transition: color 120ms ease;
}
.cg-game-card p {
    font-family: var(--font-prose, Georgia, serif);
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.4;
    margin: 0;
}

/* Privacy / policy long-form pages — generous line-height, comfortable measure,
   Cinzel headings already wired via [data-theme="brand"] h1/h2 above. */
.cg-policy {
    padding: 2.5rem 1.25rem 4rem;
    max-width: 760px;
    line-height: 1.65;
}
.cg-policy-header { margin-bottom: 2rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.cg-policy-header h1 { margin: 0; font-size: 2.4rem; }
.cg-policy-updated {
    color: var(--text-muted);
    font-family: var(--font-prose, Georgia, serif);
    font-style: italic;
    margin: 0.25rem 0 0;
}
.cg-policy-lede {
    font-family: var(--font-prose, Georgia, serif);
    font-size: 1.25rem;
    color: var(--text-primary);
    margin: 0 0 2.5rem;
}
.cg-policy section { margin: 2.5rem 0; }
.cg-policy h2 {
    font-size: 1.7rem;
    margin: 0 0 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-soft);
}
.cg-policy h3 {
    font-family: var(--font-display, 'Cinzel', Georgia, serif);
    font-weight: 600;
    font-size: 1.15rem;
    letter-spacing: 0.05em;
    color: var(--amber);
    margin: 1.6rem 0 0.5rem;
}
.cg-policy p { margin: 0.6rem 0; color: var(--text-primary); }
.cg-policy strong { color: var(--accent); font-weight: 600; }
.cg-policy ul { margin: 0.6rem 0 1rem; padding-left: 1.4rem; }
.cg-policy li { margin: 0.3rem 0; }
.cg-policy a { color: var(--accent); text-decoration: underline; text-decoration-color: rgba(212, 161, 60, 0.35); text-underline-offset: 3px; }
.cg-policy a:hover { color: var(--accent-hover); text-decoration-color: var(--accent-hover); }
.cg-policy code {
    background: var(--bg-elevated);
    color: var(--amber);
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    font-size: 0.92em;
}
.cg-policy-table {
    width: 100%;
    margin: 1rem 0 1.25rem;
    border-collapse: collapse;
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    overflow: hidden;
}
.cg-policy-table th,
.cg-policy-table td {
    padding: 0.65rem 0.85rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border-soft);
}
.cg-policy-table thead { background: var(--bg-elevated); }
.cg-policy-table th {
    color: var(--text-secondary);
    font-family: var(--font-display, 'Cinzel', Georgia, serif);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.cg-policy-table tbody tr:last-child td { border-bottom: none; }

/* Sokorogue page — retro yellow-on-black, owned by the game's own aesthetic. */
.cg-sokorogue {
    background: #000;
    color: #FFFF22;
    text-align: center;
    font-family: 'Fira Mono', monospace;
    font-size: 15px;
    line-height: 14pt;
    letter-spacing: 1px;
    padding: 1rem;
    position: relative;
}
.cg-sokorogue a { color: #FFAA88; text-decoration: none; }
.cg-sokorogue a:visited { color: #FFAA66; }
.cg-sokorogue a:hover { color: #FFAA99; }
.cg-sokorogue #canvas_Display { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.cg-sokorogue #div_Help { margin-top: 0.5rem; opacity: 0.8; }

/* Touch gamepad — D-pad bottom-left, action buttons bottom-right. Hidden on pointer:fine
   desktops; shown on touch devices and small viewports. */
.cg-soko-gamepad { display: none; }
@media (pointer: coarse), (max-width: 768px) {
    .cg-soko-gamepad {
        display: block;
        position: fixed;
        inset: 0;
        pointer-events: none;       /* let the canvas receive taps in the gaps */
        z-index: 100;
    }
}

.cg-soko-btn {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.55);
    color: var(--accent);
    border: 2px solid var(--accent);
    font-family: var(--font-display, 'Cinzel', Georgia, serif);
    font-weight: 700;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;     /* no double-tap zoom on the gamepad */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background 100ms ease, transform 80ms ease;
    margin: 0;
    padding: 0;
}
.cg-soko-btn:active {
    background: var(--accent);
    color: #0a0a0a;
    transform: scale(0.95);
}

/* D-pad: 3x3 grid with corners empty for a + shape. */
.cg-soko-dpad {
    position: absolute;
    left: max(0.75rem, env(safe-area-inset-left));
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(3, 64px);
    grid-template-rows: repeat(3, 64px);
    gap: 6px;
}
.cg-soko-dpad .cg-soko-btn {
    border-radius: 50%;
    font-size: 1.6rem;
    line-height: 1;
}
.cg-soko-up    { grid-column: 2; grid-row: 1; }
.cg-soko-left  { grid-column: 1; grid-row: 2; }
.cg-soko-right { grid-column: 3; grid-row: 2; }
.cg-soko-down  { grid-column: 2; grid-row: 3; }

/* Action stack on the right side. */
.cg-soko-actions {
    position: absolute;
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.cg-soko-actions .cg-soko-btn {
    width: 96px;
    height: 64px;
    border-radius: 12px;
    font-size: 0.95rem;
    letter-spacing: 0.15em;
}

/* Reset button — destructive action requires a long press. Internal progress bar fills
   over the hold duration; transition is restarted from 0 each time .holding is added. */
.cg-soko-restart {
    position: relative;
    overflow: hidden;
    line-height: 1.05;
}
.cg-soko-restart .cg-soko-restart-label {
    position: relative;
    z-index: 2;
    pointer-events: none;
}
.cg-soko-restart .cg-soko-restart-progress {
    position: absolute;
    inset: 0;
    z-index: 1;
    transform-origin: left center;
    transform: scaleX(0);
    background: var(--accent);
    pointer-events: none;
    /* Snap back instantly when the hold is released or completes. */
    transition: transform 0ms linear;
}
.cg-soko-restart.holding .cg-soko-restart-progress {
    transform: scaleX(1);
    /* Must match CG_RESET_HOLD_MS in Sokorogue.razor. */
    transition: transform 1000ms linear;
}
.cg-soko-restart.holding .cg-soko-restart-label {
    /* Flip the text to dark so it stays readable as gold fills behind it. */
    color: #0a0a0a;
}
/* Suppress the generic :active scale on the reset button — the progress fill is the
   feedback signal, no need for the extra wobble. */
.cg-soko-restart:active { transform: none; }

/* Tighter targets for very small landscape viewports so they don't crowd the canvas. */
@media (max-width: 480px) {
    .cg-soko-dpad { grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); }
    .cg-soko-dpad .cg-soko-btn { font-size: 1.4rem; }
    .cg-soko-actions .cg-soko-btn { width: 84px; height: 56px; font-size: 0.78rem; }
}

/* Kessler Squad — Unity WebGL stage. The topbar stays visible so the player can navigate
   back. The footer is suppressed only on this page (via :has() on the .brand wrapper) so
   the game can claim the rest of the viewport without scrolling. */
.brand:has(.cg-kesslersquad) .brand-footer { display: none; }
.brand:has(.cg-kesslersquad) .brand-main { padding: 0; display: flex; align-items: stretch; }
.brand:has(.cg-kesslersquad) .brand-topbar { position: sticky; }

.cg-kesslersquad {
    background: #000;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.cg-kesslersquad-stage {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    /* Container query unit source — lets the canvas math reference the stage's actual size. */
    container-type: size;
}

.cg-kesslersquad-canvas {
    aspect-ratio: 16 / 9;
    /* "Contain" math: take the smaller of full container width or the height-derived width
       so the 16:9 box fits inside the available area without cropping. */
    width: min(100cqw, calc(100cqh * 16 / 9));
    height: auto;
    max-height: 100cqh;
}
.cg-kesslersquad-canvas canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    background: #000;
    outline: none;
}

/* Hide the Unity template footer (logo + their own fullscreen tile) — we render our own. */
.cg-kesslersquad .footer,
.cg-kesslersquad .webgl-logo,
.cg-kesslersquad .title { display: none !important; }

.cg-kesslersquad-fullscreen {
    position: absolute;
    bottom: 0.85rem;
    right: 0.85rem;
    z-index: 10;
    background: rgba(0, 0, 0, 0.65);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.3rem 0.55rem;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background 140ms ease, color 140ms ease, transform 100ms ease;
    margin: 0;
}
.cg-kesslersquad-fullscreen:hover {
    background: var(--accent);
    color: #0a0a0a;
}
.cg-kesslersquad-fullscreen:active { transform: translateY(1px); }

/* Touch-primary devices need a much bigger tap target — bump everything ~3x so the
   fullscreen control is comfortably hittable with a thumb. Also nudge it further from
   the screen edge so phone-safe-area rounding doesn't clip it. */
@media (pointer: coarse), (max-width: 768px) {
    .cg-kesslersquad-fullscreen {
        bottom: 1.5rem;
        right: 1.5rem;
        padding: 1rem 1.35rem;
        font-size: 3rem;
        border-width: 2px;
        border-radius: calc(var(--radius) + 4px);
    }
}

/* Hide the fullscreen button while we're actually IN fullscreen — separate rules per
   prefix because grouped pseudo-classes are dropped if any selector is unknown. */
.cg-kesslersquad-stage:fullscreen .cg-kesslersquad-fullscreen { display: none; }
.cg-kesslersquad-stage:-webkit-full-screen .cg-kesslersquad-fullscreen { display: none; }
.cg-kesslersquad-stage:-ms-fullscreen .cg-kesslersquad-fullscreen { display: none; }

.cg-orientation-msg {
    display: none;
    position: fixed;
    inset: 0;
    flex-direction: column;
    color: rgba(255, 255, 255, 0.95);
    background: #000;
    font-size: 1.2em;
    text-align: center;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 24px;
    gap: 1.25rem;
}
.cg-orientation-msg p { margin: 0; max-width: 32ch; }
.cg-orientation-ignore {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 999px;
    padding: 0.5rem 1.6rem;
    font-family: var(--font-display, 'Cinzel', Georgia, serif);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
    margin: 0;
}
.cg-orientation-ignore:hover {
    background: var(--accent);
    color: #0a0a0a;
    box-shadow: 0 0 0 3px rgba(212, 161, 60, 0.22);
}
