/* ── Design Tokens ──────────────────────────────────────────── */
:root {
    --surface-page:    #eef2f7;
    --surface-card:    #ffffff;
    --surface-input:   #ffffff;
    --border:          #d1d9e0;
    --border-input:    #64748b;
    --border-subtle:   #e2e8f0;
    --text-muted:      #475569;
    --surface-sidebar: #ffffff;
    --surface-topbar:  #ffffff;
    --sidebar-text:    inherit;
    --sidebar-border:  #eaedf1;
    --btn-primary-bg:  #02014a;
    --btn-primary-hover: #526db9;
}

.dark {
    --surface-page:    #020617;
    --surface-card:    #1e293b;
    --surface-input:   #0f172a;
    --border:          #334155;
    --border-subtle:   #1e293b;
    --text-muted:      #94a3b8;
    --surface-sidebar: #1e293b;
    --surface-topbar:  #1e293b;
    --sidebar-text:    inherit;
    --sidebar-border:  #1e293b;
    --btn-primary-bg:  #3b82f6;
    --btn-primary-hover: #60a5fa;
}

/* ── Global surfaces ────────────────────────────────────────── */
html, body {
    font-family: ui-sans-serif, system-ui, sans-serif;
    height: 100%;
    margin: 0;
    background-color: var(--surface-page) !important;
}

/* ── Card surfaces (light mode) ─────────────────────────────── */
:root:not(.dark) .bg-white {
    border-color: var(--border) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
}

/* ── CTA buttons: deep navy in light, blue in dark ──────────── */
:root:not(.dark) .bg-blue-600 {
    background-color: var(--btn-primary-bg) !important;
}
:root:not(.dark) .hover\:bg-blue-500:hover,
:root:not(.dark) .hover\:bg-blue-600:hover {
    background-color: var(--btn-primary-hover) !important;
}

/* ── Input field ────────────────────────────────────────────── */
/* !important guards against Tailwind CDN dynamic injection winning the cascade */
.input-warm {
    background: #ffffff !important;
    border: 1.5px solid #64748b !important;
    color: #1a1a1a !important;
    transition: border-color .15s, box-shadow .15s;
}

.dark .input-warm {
    background: #0f172a !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

/* Doubles pairing-letter cells: color set inline per-letter via style="" so matching letters
   are visually linked as a pair. Overrides .input-warm's background/color !important. */
.input-warm.pair-letter[style] {
    background: var(--pair-bg) !important;
    color: var(--pair-fg) !important;
    border-color: var(--pair-fg) !important;
}

.input-warm::placeholder {
    color: #a8a29e !important;
}

.dark .input-warm::placeholder {
    color: #64748b !important;
}

.input-warm:focus {
    outline: none !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12) !important;
}

.dark .input-warm:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
}

.input-warm:-webkit-autofill,
.input-warm:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #ffffff inset !important;
    -webkit-text-fill-color: #1a1a1a !important;
}

.dark .input-warm:-webkit-autofill,
.dark .input-warm:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #0f172a inset !important;
    -webkit-text-fill-color: #e2e8f0 !important;
}


#app {
    height: 100%;
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem;
}

.loading-progress circle {
    fill: none;
    stroke: #e5e7eb;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #3b82f6;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 600;
    inset: calc(20vh + 3.25rem) 0 auto;
    color: #6b7280;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

#blazor-error-ui {
    background: #fef3c7;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

@media print {
    body > #app { display: none !important; }
    .print-target { display: block !important; }
}

/* ── Suppress focus ring on headings (set programmatically by Blazor enhanced nav) ── */
h1:focus, h2:focus, h3:focus {
    outline: none !important;
}

/* ── Mobile / Responsive additions ─────────────────────────── */

/* Remove 300ms tap delay on interactive elements */
button, a, input, select, textarea {
    touch-action: manipulation;
}

/* Bottom tab bar — iOS home indicator safe area */
.mobile-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
}

/* Bracket horizontal scroll with smooth iOS inertial scroll */
.bracket-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

/* Tournament detail tab bar — right fade hint for hidden tabs */
.tab-scroll-fade {
    position: relative;
}
.tab-scroll-fade::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 32px;
    background: linear-gradient(to left, var(--surface-topbar), transparent);
    pointer-events: none;
    z-index: 1;
}

/* Print documents — reduce padding/font on mobile screen view */
@media screen and (max-width: 768px) {
    .print-doc {
        padding: 12px !important;
        font-size: 11px !important;
    }
    .print-doc table {
        font-size: 10px !important;
    }
    .print-doc table td,
    .print-doc table th {
        padding: 4px 6px !important;
    }
}
