/* ═══════════════════════════════════════════════════════════════
   АААА АРЕНА - Global Styles
   Medieval Tavern Board Game Theme
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   TYPOGRAPHY - Medieval themed with full Cyrillic & Latin support

   Font Stack (loaded in _Layout.cshtml for faster rendering):
   - Display:  Cormorant SC (elegant small caps, old document feel)
   - Heading:  Cormorant Garamond (refined serif, vintage character)
   - Body:     Literata (book-like serif, excellent readability)
   - Accent:   Old Standard TT (classic printing press style)
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────
   CSS VARIABLES
   ───────────────────────────────────────────────────────────────── */
:root {
    /* Parchment tones */
    --parchment-lightest: #faf8f4;
    --parchment-light: #f4e4bc;
    --parchment: #e8d4a8;
    --parchment-dark: #d4c090;
    --parchment-aged: #c9b896;
    --parchment-burned: #b8a070;

    /* Wood tones - Dark oak */
    --wood-lightest: #5c4033;
    --wood-light: #4a3428;
    --wood: #3d2b1f;
    --wood-dark: #2a1c10;
    --wood-darkest: #1a1008;

    /* Leather binding */
    --leather-light: #5c3d2e;
    --leather: #3d2820;
    --leather-dark: #2a1a14;

    /* Metal accents */
    --brass-light: #ffd700;
    --brass: #daa520;
    --brass-dark: #b8860b;
    --brass-darkest: #8b6508;
    --gold: #ffd700;
    --gold-dim: #c5a000;

    /* Ink colors */
    --ink-black: #1a1408;
    --ink-brown: #3d2b1f;
    --ink-red: #8b0000;
    --ink-red-light: #a52a2a;
    --ink-green: #2d5a27;
    --ink-green-light: #4a7c40;

    /* UI States */
    --success: #4a7c40;
    --success-light: #6b9d5f;
    --warning: #b8860b;
    --danger: #8b0000;
    --danger-light: #a52a2a;

    /* Shadows */
    --shadow-soft: rgba(26, 16, 8, 0.2);
    --shadow-medium: rgba(26, 16, 8, 0.4);
    --shadow-hard: rgba(26, 16, 8, 0.6);
    --shadow-deep: rgba(0, 0, 0, 0.5);

    /* Fonts - Full Cyrillic & Latin support */
    --font-display: 'Cormorant SC', 'Old Standard TT', Georgia, serif;
    --font-heading: 'Cormorant Garamond', 'Old Standard TT', Georgia, serif;
    --font-body: 'Literata', 'Old Standard TT', Georgia, serif;
    --font-accent: 'Old Standard TT', Georgia, serif;
    --font-mono: 'Courier New', monospace;

    /* Candlelight glow */
    --candle-glow: rgba(255, 150, 50, 0.15);
    --candle-ambient: rgba(255, 120, 40, 0.08);
}

/* ─────────────────────────────────────────────────────────────────
   GLOBAL RESETS & BASE STYLES
   ───────────────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Ensure proper mobile scaling */
    font-size: 16px;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    font-family: var(--font-body);
    color: var(--ink-brown);

    /* Prevent iOS overscroll */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;

    /* Dark tavern wood as default background */
    background:
        url("data:image/svg+xml,%3Csvg width='200' height='200' viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='grain' width='100' height='8' patternUnits='userSpaceOnUse'%3E%3Cpath d='M0 4 Q25 2 50 4 T100 4' stroke='%23241a10' stroke-width='1' fill='none' opacity='0.4'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='200' height='200' fill='url(%23grain)'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E"),
        radial-gradient(ellipse at 50% 30%, #3d2a1a 0%, #2a1c10 40%, #1a1008 100%);
    background-attachment: fixed;
}

/* Canvas optimization */
canvas {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    touch-action: none;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: contents;
}

/* Focus states */
h1:focus, h2:focus, h3:focus {
    outline: none;
}

/* ─────────────────────────────────────────────────────────────────
   TYPOGRAPHY
   ───────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--ink-brown);
    margin: 0;
}

p {
    font-family: var(--font-body);
    line-height: 1.6;
}

/* ─────────────────────────────────────────────────────────────────
   FORM ELEMENTS
   ───────────────────────────────────────────────────────────────── */
input, button, textarea, select {
    font-family: inherit;
}

input:focus, textarea:focus, select:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 2px solid var(--success);
}

.invalid {
    outline: 2px solid var(--danger);
}

.validation-message {
    color: var(--danger);
    font-family: var(--font-body);
}

/* ─────────────────────────────────────────────────────────────────
   ERROR BOUNDARIES
   ───────────────────────────────────────────────────────────────── */
.blazor-error-boundary {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-light) 100%);
    padding: 1rem 1rem 1rem 1.5rem;
    color: var(--parchment-light);
    font-family: var(--font-body);
    border: 3px solid var(--brass-darkest);
    border-radius: 4px;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

#blazor-error-ui {
    background: linear-gradient(180deg, var(--danger-light), var(--danger));
    color: var(--parchment-light);
    font-family: var(--font-body);
    padding: 1rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: none;
    text-align: center;
    border-top: 2px solid var(--brass-darkest);
}

#blazor-error-ui a {
    color: var(--brass-light);
}

/* ─────────────────────────────────────────────────────────────────
   UTILITY CLASSES
   ───────────────────────────────────────────────────────────────── */

/* Parchment texture background */
.parchment-bg {
    background:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='paper'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.04' numOctaves='5'/%3E%3CfeColorMatrix values='0 0 0 0 0.93 0 0 0 0 0.87 0 0 0 0 0.75 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23paper)'/%3E%3C/svg%3E"),
        linear-gradient(170deg, #ede0c8 0%, #e6d5b8 25%, #dcc8a0 50%, #d4bc90 75%, #c9ad80 100%);
}

/* Burned edge effect for cards */
.burned-edge {
    position: relative;
}

.burned-edge::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow:
        inset 0 0 40px rgba(80, 50, 20, 0.5),
        inset 0 0 80px rgba(60, 30, 10, 0.3);
    pointer-events: none;
}

/* Brass/metal button style */
.brass-button {
    background: linear-gradient(180deg, var(--brass) 0%, var(--brass-dark) 50%, var(--brass-darkest) 100%);
    border: 2px solid var(--wood);
    color: var(--wood-darkest);
    font-family: var(--font-heading);
    font-weight: 600;
    text-shadow: 0 1px 0 rgba(255, 215, 0, 0.3);
    box-shadow:
        0 4px 8px var(--shadow-medium),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    cursor: pointer;
    padding: 12px 24px;
    border-radius: 4px;
}

.brass-button:hover {
    background: linear-gradient(180deg, var(--brass-light) 0%, var(--brass) 50%, var(--brass-dark) 100%);
    transform: translateY(-2px);
    box-shadow:
        0 6px 12px var(--shadow-medium),
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.brass-button:active {
    transform: translateY(0);
    box-shadow:
        0 2px 4px var(--shadow-soft),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

/* Wax seal decoration */
.wax-seal {
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 30% 30%, #c41e3a 0%, #8b0000 50%, #5c0000 100%);
    border-radius: 50%;
    box-shadow:
        0 4px 8px var(--shadow-hard),
        inset 0 2px 4px rgba(255, 255, 255, 0.2),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    color: var(--parchment-light);
    font-size: 1.5rem;
    font-weight: 700;
}

/* Brass coin/token */
.brass-coin {
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--brass-light) 0%, var(--brass) 40%, var(--brass-dark) 70%, var(--brass-darkest) 100%);
    box-shadow:
        inset 0 3px 6px rgba(255,255,255,0.4),
        inset 0 -3px 6px rgba(0,0,0,0.3),
        0 4px 12px rgba(0,0,0,0.3);
    border: 2px solid var(--brass-darkest);
}

/* Leather frame effect */
.leather-frame {
    box-shadow:
        0 0 0 3px var(--leather-light),
        0 0 0 6px var(--leather),
        0 0 0 8px var(--leather-dark);
}

/* Candlelight glow effect */
.candle-glow {
    box-shadow: 0 0 80px var(--candle-glow);
}

/* ─────────────────────────────────────────────────────────────────
   SCROLLBAR STYLING
   ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--wood-dark);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--brass-dark), var(--brass-darkest));
    border-radius: 4px;
    border: 1px solid var(--wood-darkest);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--brass), var(--brass-dark));
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--brass-dark) var(--wood-dark);
}

/* ─────────────────────────────────────────────────────────────────
   SELECTION STYLING
   ───────────────────────────────────────────────────────────────── */
::selection {
    background: var(--brass);
    color: var(--wood-darkest);
}

::-moz-selection {
    background: var(--brass);
    color: var(--wood-darkest);
}
