/* =========================================================================
   Asobi Dashboard — Warm Workshop
   Light cream surfaces · Fraunces display · coral accents · paper grain
   Matches the asobi.dev marketing site design system.
   ========================================================================= */

:root {
    /* Surfaces — warm cream layering */
    --bg:               #fbf6ec;
    --surface:          #f7f0e2;
    --surface-raised:   #f4ead6;
    --surface-hover:    #f0e2c6;
    --surface-active:   #e8d8b8;
    --surface-overlay:  rgba(251, 246, 236, 0.88);

    /* Text — warm ink hierarchy */
    --text:             #1a1208;
    --text-secondary:   #6b5636;
    --text-muted:       #9a8258;
    --text-inverse:     #fbf6ec;

    /* Brand accents */
    --primary:          #ef5b3c;
    --primary-hover:    #ff6f4e;
    --primary-deep:     #c9452a;
    --primary-muted:    rgba(239, 91, 60, 0.10);
    --primary-border:   rgba(239, 91, 60, 0.25);
    --secondary:        #d18f5a;

    /* Semantic */
    --success:          #2a8e3e;
    --success-muted:    rgba(42, 142, 62, 0.10);
    --danger:           #c9452a;
    --danger-muted:     rgba(201, 69, 42, 0.08);
    --danger-border:    rgba(201, 69, 42, 0.25);
    --warning:          #e38b1f;
    --warning-muted:    rgba(227, 139, 31, 0.10);

    /* Structure */
    --line:             #e6d5b2;
    --line-strong:      #c7ad7f;
    --ring:             rgba(239, 91, 60, 0.35);

    /* Radii — chunky, friendly */
    --r-1:              6px;
    --r-2:              12px;
    --r-3:              999px;

    /* Typography */
    --font-display:     'Fraunces', ui-serif, Georgia, serif;
    --font-body:        'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
    --font-mono:        'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;

    /* Motion */
    --ease:             cubic-bezier(0.2, 0.7, 0.1, 1);
    --dur:              150ms;

    /* Grain overlay */
    --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.20 0 0 0 0 0.14 0 0 0 0 0.06 0 0 0 0.10 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* =========================================================================
   Reset & base
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-body);
    font-feature-settings: 'ss01', 'cv11';
    font-size: 1rem;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    position: relative;
}

/* Paper-grain texture — tactile warmth */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
    background-image: var(--grain);
    opacity: 0.45;
    mix-blend-mode: multiply;
}

::selection { background: var(--primary); color: #fff; }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--r-1);
}

a { color: var(--primary-deep); text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover { color: var(--primary); }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 500;
    font-style: italic;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* =========================================================================
   Navigation
   ========================================================================= */
.nav {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0 2rem;
    height: 60px;
    background: color-mix(in oklab, var(--bg) 82%, transparent);
    backdrop-filter: saturate(140%) blur(14px);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.15rem;
    font-style: italic;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
}
.nav-brand:hover { color: var(--text); }

.nav-logo {
    height: 36px;
    width: auto;
    display: block;
    object-fit: contain;
    transform-origin: 16% 62%;
    transition: transform var(--dur) var(--ease);
    filter: drop-shadow(0 2px 6px rgba(239, 91, 60, 0.16));
}
.nav-brand:hover .nav-logo { transform: translateX(1px) rotate(-1.5deg); }

.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: var(--r-1);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all var(--dur) var(--ease);
    position: relative;
}

.nav-links a:hover { color: var(--text-secondary); background: var(--surface-hover); }
.nav-links a.active {
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(26, 18, 8, 0.06);
}

.nav-user { margin-left: auto; }

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: var(--r-3);
    border: 1px solid var(--line);
}

.user-name { color: var(--text-secondary); font-weight: 500; }

.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--r-1);
    transition: all var(--dur) var(--ease);
    font-family: var(--font-body);
}
.btn-link:hover { color: var(--danger); background: var(--danger-muted); }

/* =========================================================================
   Main content
   ========================================================================= */
.main {
    max-width: 980px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
}

/* =========================================================================
   Page header
   ========================================================================= */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-variation-settings: 'SOFT' 50;
}

.page-header h2 {
    font-size: 1.2rem;
}

/* =========================================================================
   Cards
   ========================================================================= */
.card {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-2);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: border-color var(--dur) var(--ease);
}
.card:hover { border-color: var(--line-strong); }

.card-title {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-bottom: 1rem;
}

/* =========================================================================
   Stat grid
   ========================================================================= */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-2);
    padding: 1.25rem 1.5rem;
    transition: all 200ms var(--ease);
    position: relative;
    overflow: hidden;
}

.stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    opacity: 0;
    transition: opacity 200ms var(--ease);
}

.stat:hover { border-color: var(--primary-border); }
.stat:hover::before { opacity: 1; }

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 0.4rem;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 400;
    font-style: italic;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variation-settings: 'SOFT' 40;
}

.stat-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* =========================================================================
   Tables
   ========================================================================= */
table, .table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

thead th, .table thead th {
    text-align: left;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
}

tbody td, .table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
    vertical-align: middle;
}

tbody tr, .table tbody tr {
    transition: background var(--dur) var(--ease);
}
tbody tr:hover, .table tbody tr:hover {
    background: var(--surface-hover);
}
tbody tr:last-child td, .table tbody tr:last-child td {
    border-bottom: none;
}

/* =========================================================================
   Buttons
   ========================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--r-1);
    font-weight: 550;
    font-size: 0.875rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--dur) var(--ease);
    font-family: var(--font-body);
    letter-spacing: 0;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary-deep);
    box-shadow: 0 1px 2px rgba(201, 69, 42, 0.15);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(239, 91, 60, 0.2);
}
.btn-primary:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(201, 69, 42, 0.15); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--line);
}
.btn-ghost:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger-border);
}
.btn-danger:hover { background: var(--danger-muted); }

.btn-success {
    background: var(--success-muted);
    color: var(--success);
}
.btn-success:hover { background: var(--success); color: #fff; }

.btn-warning {
    background: var(--warning-muted);
    color: var(--warning);
}
.btn-warning:hover { background: var(--warning); color: #fff; }

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
}

.btn-group {
    display: flex;
    gap: 0.4rem;
}

/* =========================================================================
   Forms
   ========================================================================= */
.form-group { margin-bottom: 1rem; }

.form-label {
    display: block;
    font-weight: 550;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    letter-spacing: 0.01em;
}

.form-input, .form-select, select.form-input {
    width: 100%;
    padding: 0.55rem 0.8rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-1);
    color: var(--text);
    font-size: 0.9rem;
    font-family: var(--font-body);
    transition: all var(--dur) var(--ease);
    outline: none;
    appearance: none;
}

.form-input:focus, .form-select:focus, select.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}

.form-input::placeholder { color: var(--text-muted); }

.form-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

/* =========================================================================
   Badges
   ========================================================================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: var(--r-3);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.badge-active { background: var(--success-muted); color: var(--success); }
.badge-inactive { background: var(--surface-raised); color: var(--text-muted); }
.badge-warning { background: var(--warning-muted); color: var(--warning); }
.badge-error { background: var(--danger-muted); color: var(--danger); }
.badge-revoked { background: var(--danger-muted); color: var(--danger); }
.badge-plan { background: var(--primary-muted); color: var(--primary); }
.badge-free { background: var(--primary-muted); color: var(--primary); }

/* =========================================================================
   Alerts
   ========================================================================= */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--r-1);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-success {
    background: var(--success-muted);
    border: 1px solid rgba(42, 142, 62, 0.2);
    color: var(--success);
}

.alert-error {
    background: var(--danger-muted);
    border: 1px solid var(--danger-border);
    color: var(--danger);
}

/* =========================================================================
   Key display
   ========================================================================= */
.key-display {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--surface-raised);
    padding: 0.65rem 0.85rem;
    border-radius: var(--r-1);
    border: 1px solid var(--success);
    margin: 0.5rem 0;
    word-break: break-all;
    color: var(--success);
}

.key-warning {
    font-size: 0.8rem;
    color: var(--warning);
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* =========================================================================
   Empty state
   ========================================================================= */
.empty-state {
    text-align: center;
    padding: 4rem 1.5rem;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 1rem;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* =========================================================================
   Game cards (legacy compat)
   ========================================================================= */
.game-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-2);
    margin-bottom: 0.6rem;
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    text-decoration: none;
    color: var(--text);
}

.game-card:hover {
    border-color: var(--primary-border);
    background: var(--surface);
    transform: translateX(3px);
}

.game-card-info h3 {
    font-family: var(--font-body);
    font-style: normal;
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
    letter-spacing: -0.01em;
}

.game-card-info .game-slug {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.game-card-meta {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* =========================================================================
   Sections
   ========================================================================= */
.section { margin-bottom: 2.5rem; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 500;
    font-style: italic;
    letter-spacing: -0.01em;
}

/* =========================================================================
   Environment tabs
   ========================================================================= */
.env-tabs {
    display: flex;
    gap: 2px;
    background: var(--line);
    border-radius: var(--r-1);
    padding: 2px;
    width: fit-content;
    margin-bottom: 1.5rem;
}

.env-tab {
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 550;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    border: none;
    font-family: var(--font-body);
    transition: all var(--dur) var(--ease);
}

.env-tab:hover { color: var(--text-secondary); }
.env-tab.active {
    color: var(--text);
    background: var(--bg);
    box-shadow: 0 1px 3px rgba(26, 18, 8, 0.08);
}

/* =========================================================================
   Settings
   ========================================================================= */
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--line);
}

.settings-row:last-child { border-bottom: none; }
.settings-label { font-size: 0.85rem; color: var(--text-muted); }
.settings-value { font-weight: 550; }

/* =========================================================================
   Modal
   ========================================================================= */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--surface-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-2);
    padding: 1.75rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(26, 18, 8, 0.12), 0 4px 16px rgba(26, 18, 8, 0.06);
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 500;
    font-style: italic;
    margin-bottom: 1.25rem;
    letter-spacing: -0.01em;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* =========================================================================
   Landing / login page
   ========================================================================= */
.landing-body { background: var(--bg); }

.landing {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 2rem;
}

/* Cloaked tanuki greets you from the side on wide screens. Hidden on
   narrow viewports so the centered auth column stays uncluttered. */
.landing-mascot {
    position: absolute;
    top: 50%;
    right: clamp(40px, calc(50% - 480px), 12vw);
    width: clamp(280px, 28vw, 420px);
    height: auto;
    transform: translateY(-50%) rotate(-4deg);
    pointer-events: none;
    user-select: none;
    z-index: 0;
    filter:
        drop-shadow(0 18px 36px rgba(239, 91, 60, 0.16))
        drop-shadow(0 6px 12px rgba(26, 18, 8, 0.10));
    animation:
        landing-mascot-in 900ms cubic-bezier(0.16, 1, 0.3, 1) 200ms backwards,
        landing-mascot-float 8s ease-in-out 1.1s infinite;
    transform-origin: 60% 70%;
}

@keyframes landing-mascot-in {
    from { opacity: 0; transform: translateY(-44%) rotate(-12deg) scale(0.92); }
    to   { opacity: 1; transform: translateY(-50%) rotate(-4deg) scale(1); }
}
@keyframes landing-mascot-float {
    0%, 100% { transform: translateY(-50%) rotate(-4deg); }
    50%      { transform: translateY(calc(-50% - 10px)) rotate(-2deg); }
}

@media (max-width: 1024px) {
    .landing-mascot { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .landing-mascot { animation: none; }
}

.landing > :not(.landing-mascot) { position: relative; z-index: 1; }

.landing-logo {
    width: auto;
    height: 180px;
    object-fit: contain;
    display: block;
    margin: 0 auto 1.75rem;
    filter:
        drop-shadow(0 12px 24px rgba(239, 91, 60, 0.18))
        drop-shadow(0 4px 8px rgba(26, 18, 8, 0.08));
    animation: landing-logo-in 800ms cubic-bezier(0.16, 1, 0.3, 1) 80ms backwards,
               landing-logo-float 7s ease-in-out 900ms infinite;
    transform-origin: 50% 80%;
}

@keyframes landing-logo-in {
    from { opacity: 0; transform: translateY(12px) scale(0.94) rotate(-3deg); }
    to   { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}
@keyframes landing-logo-float {
    0%, 100% { transform: translateY(0) rotate(0); }
    50%      { transform: translateY(-6px) rotate(1deg); }
}
@media (prefers-reduced-motion: reduce) {
    .landing-logo { animation: none; }
}

.landing h1 {
    font-size: 2.75rem;
    font-variation-settings: 'SOFT' 60;
    margin-bottom: 0.6rem;
}

.landing p {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-bottom: 2.25rem;
    max-width: 440px;
    line-height: 1.7;
}

.auth-container { max-width: 380px; width: 100%; }

.auth-form .form-input {
    margin-bottom: 0.6rem;
}

.auth-error {
    padding: 0.6rem 0.8rem;
    border-radius: var(--r-1);
    background: var(--danger-muted);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.btn-github {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1.5rem;
    background: var(--text);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--r-1);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--dur) var(--ease);
    font-family: var(--font-body);
    box-shadow: 0 2px 6px rgba(26, 18, 8, 0.12);
}

.btn-github:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(26, 18, 8, 0.18);
}
.btn-github:active { transform: translateY(0); }
.btn-github svg { width: 20px; height: 20px; }

/* =========================================================================
   Utility
   ========================================================================= */
.font-mono { font-family: var(--font-mono); font-size: 0.85rem; letter-spacing: 0.01em; }
.text-sm { font-size: 0.8rem; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.mono { font-family: var(--font-mono); font-size: 0.8rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none; }

/* =========================================================================
   Scrollbar — subtle, warm
   ========================================================================= */
::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 768px) {
    .nav { padding: 0 1rem; gap: 1rem; }
    .main { padding: 1.5rem 1rem; }
    .page-header h1 { font-size: 1.35rem; }
    .stat-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .landing h1 { font-size: 2rem; }
    .landing-logo { height: 140px; }
    .nav-links { display: none; }
}
