@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700;800&family=JetBrains+Mono:wght@500;700&family=Exo 2:wght@500;600;700&family=Plus Jakarta Sans:wght@500;600;700&display=swap');

/* Central theme variables (non-invasive)
   This file defines CSS variables and optional helper classes.
   It intentionally avoids broad element selectors to prevent
   overriding Tailwind or existing hover/toolbar behaviors.
*/

:root {
   /* Colors - dark theme */
   --color-primary: #991b1b;    /* Deep Red */
   --color-secondary: #111827;  /* Near Black */
   --color-accent: #ef4444;     /* Bright Red */
   --color-body-bg: #fdf2f2;    /* Very light red tint */
   --color-body-text: #1f2937;  /* Dark Gray */
   --color-muted: #6b7280;
   --color-border: rgba(0,0,0,0.1);

    /* Radii - refined modern edges, 3-4px */
    --radius-sm: 3px;
    --radius-md: 3px;
    --radius-lg: 4px;

   /* Fonts */
/* Professional Sans-Serif for readability */
   --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
   
   /* Bold, impactful font for headings */
    --font-heading: 'Exo 2', Georgia, serif;

   /* Sharp, technical font for Elo and match stats */
   --font-mono: 'JetBrains Mono', monospace;

   /* Sizes & spacing (compact) */
   --font-size-base: 15px;
   --space-sm: 0.4rem; /* ~6px */
   --space-md: 0.6rem; /* ~10px */
   --space-lg: 1rem;   /* replaces larger paddings like p-6 */
   /* Header icon vertical nudge (change this to manually adjust alignment) */
    --header-icon-nudge: 1px;
   /* Header icon horizontal offset (positive moves icon right) */
   --header-icon-offset-x: 3px;
}

.header-favicon {
    width: 1.25rem;
    height: 1.25rem;
    object-fit: cover;
    border-radius: var(--radius-sm);
    vertical-align: middle;
    
    /* Adds offset: X (horizontal) and Y (vertical) */
    translate: 6px -1.5px; 
}

.font-sans {
    font-family: var(--font-sans) !important;
}

html, body { 
    font-family: var(--font-sans) !important; 
}

/* Apply fonts globally */
body {
    font-family: var(--font-sans);
    min-height: 100vh;
    color: var(--color-body-text);
    background-color: #fdf6f4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

::selection {
    background: rgba(153, 27, 27, 0.16);
    color: var(--color-body-text);
}

:where(a, button, input, textarea, select, summary):focus-visible {
    outline: 2px solid rgba(153, 27, 27, 0.55);
    outline-offset: 3px;
}

/* Modern button styling */
button, input[type="button"], input[type="submit"], .btn-hover {
    border-radius: var(--radius-md) !important;
    box-shadow: none !important;
    border: 1px solid transparent !important;
    transition: all 0.2s ease !important;
}

button:hover, input[type="button"]:hover, input[type="submit"]:hover, .btn-hover:hover {
    box-shadow: none !important;
}

/* Modern input styling */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
    border-radius: var(--radius-md) !important;
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
    transition: border-color 0.2s ease !important;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
    box-shadow: 0 0 0 3px rgba(153, 27, 27, 0.08) !important;
    border-color: #991b1b !important;
}

h1, h2, h3, .font-bold { 
    font-family: var(--font-heading) !important; 
    font-weight: 800; 
    letter-spacing: -0.025em !important; /* Fixed property name */
}
/* Create a utility for your numbers */
.font-mono { 
    font-family: var(--font-mono) !important; 
    letter-spacing: -0.05em; /* Tighter mono looks more modern */
}

/* Optional helper classes - use these when you want site-wide consistency
   They are intentionally namespaced with `site-` / `custom-` to avoid clashing
   with Tailwind utility classes. */

.site-font-sans { font-family: var(--font-sans); }
.site-font-heading { font-family: var(--font-heading); }

.site-radius-sm { border-radius: var(--radius-sm); }
.site-radius-md { border-radius: var(--radius-md); }
.site-radius-lg { border-radius: var(--radius-lg); }

.site-bg-primary { background-color: var(--color-primary); }
.site-bg-secondary { background-color: var(--color-secondary); }
.site-text-accent { color: var(--color-accent); }

/* Example button style you can apply to elements explicitly: */
.site-btn {
  background-color: var(--color-accent);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

.site-btn:focus { outline: 2px solid rgba(59,130,246,0.3); outline-offset: 2px; }
.site-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.site-btn:focus-visible {
    outline: 2px solid rgba(153, 27, 27, 0.55);
    outline-offset: 3px;
}

/* Small utilities */
.site-border { border: 1px solid var(--color-border); }
.site-muted { color: var(--color-muted); }

/* Nothing here targets bare `a`, `button`, or `header` selectors so existing
   Tailwind hover and toolbar behaviours remain unchanged. */

/* Compatibility overrides: map common Tailwind utility classes to the
   central CSS variables so changing variables updates the site.
   These are conservative and limited to the utilities used in your pages. */

/* Radii - force mappings to CSS variables so changes apply consistently */
.rounded { border-radius: var(--radius-md) !important; }
.rounded-sm { border-radius: var(--radius-sm) !important; }
.rounded-md { border-radius: var(--radius-md) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }
.rounded-xl { border-radius: calc(var(--radius-lg) + 4px) !important; }
.rounded-2xl { border-radius: calc(var(--radius-lg) + 8px) !important; }
.rounded-3xl { border-radius: calc(var(--radius-lg) + 12px) !important; }
.rounded-full { border-radius: 9999px !important; }

/* Override arbitrary bracketed Tailwind-style radii like `rounded-[2rem]` so
   they don't produce inconsistent, very large radii. This targets only
   classes that include a `rounded-[` pattern. */
[class*="rounded-["] {
    border-radius: var(--radius-md) !important;
}

/* ------------------------------------------------------------------
   Force consistent, sharp radii for all container-like elements inside
   the main content area and common modal/dialog containers.
   This is intentionally opinionated: it applies `--radius-md` everywhere
   in the content area so no element appears out-of-place.
   If you'd like exceptions (badges, avatars), I can whitelist them.
   ------------------------------------------------------------------ */
#main-content, #main-content * {
    border-radius: var(--radius-md) !important;
}

/* Also ensure modals / overlays follow the same sharp radius */
[id$="Modal"], .modal, .modal * {
    border-radius: var(--radius-md) !important;
}

/* Keep interactive controls visually consistent too */
input, textarea, select, button {
    border-radius: var(--radius-md) !important;
}


/* Colors */
.bg-blue-800 { background-color: var(--color-primary) !important; }
.bg-blue-900 { background-color: var(--color-secondary) !important; }
.bg-blue-600 { background-color: var(--color-accent) !important; }
.text-slate-900 { color: var(--color-body-text) !important; }
.text-slate-600 { color: var(--color-muted) !important; }
.border-slate-200 { border-color: var(--color-border) !important; }
.bg-blue-50 { background-color: rgba(96,165,250,0.06) !important; }
.bg-blue-100 { background-color: rgba(96,165,250,0.12) !important; }
.border-blue-100 { border-color: rgba(96,165,250,0.12) !important; }
.border-l-blue-800 { border-left-color: var(--color-primary) !important; }
.text-blue-800 { color: var(--color-primary) !important; }
.text-blue-700 { color: var(--color-primary) !important; }

/* Small badge / pill backgrounds often use blue-50 / blue-100 */
.bg-blue-50.text-blue-800, .bg-blue-50 { background-color: rgba(96,165,250,0.06); }
.bg-blue-100.text-blue-800, .bg-blue-100 { background-color: rgba(96,165,250,0.12); }

/* Keep these overrides narrow — if you'd like broader coverage I can
   expand the mappings or switch to a Tailwind config approach. */

/* Spacing (compact mappings) */
.p-6 { padding: 0.6rem !important; }
.p-5 { padding: calc(var(--space-lg) - 0.25rem) !important; }
.p-3 { padding: var(--space-md) !important; }
.p-2 { padding: var(--space-sm) !important; }
.px-4 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
.py-4 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.px-6 { padding-left: calc(var(--space-lg)) !important; padding-right: calc(var(--space-lg)) !important; }
.py-3 { padding-top: var(--space-md) !important; padding-bottom: var(--space-md) !important; }

/* Reduce large grid gaps and card paddings so tiles sit closer together */
.gap-6 { gap: 0.6rem !important; }
.grid.gap-6 { gap: 0.6rem !important; }

/* Make home panels and dynamically created cards more compact by default */
.home-panel { padding: 0.6rem !important; }
.bg-white.rounded-3xl, #analytics-summary div, #analytics-highlights div { padding: 0.6rem !important; }

/* Compact utilities for common layout containers */
.max-w-4xl.p-6 { padding-left: var(--space-lg); padding-right: var(--space-lg); }
.mb-8 { margin-bottom: calc(var(--space-lg)); }

/* ------------------------------------------------------------------
   Final enforcement: ensure all card-like elements use the theme radius
   This block appears last so it overrides earlier conflicted rules.
   Targets common card utilities and any rounded-* utilities inside
   the main content area and modals.
   ------------------------------------------------------------------ */
#main-content .rounded-2xl,
#main-content .rounded-3xl,
#main-content [class*="rounded-"],
#main-content [class*="rounded\["],
#main-content .bg-white,
#main-content .shadow-sm,
#main-content .card-hover,
#main-content .home-panel,
#main-content #analytics-summary div,
#main-content #analytics-highlights div,
#main-content .rounded {
    border-radius: var(--radius-md) !important;
}

[id$="Modal"] .rounded-2xl,
[id$="Modal"] .rounded-3xl,
[id$="Modal"] [class*="rounded-"],
[id$="Modal"] .bg-white,
[id$="Modal"] .shadow-sm,
[id$="Modal"] .card-hover {
    border-radius: var(--radius-md) !important;
}

/* Header icon alignment: nudge small inline SVGs in text links to vertically center with text */
header nav a svg {
   vertical-align: middle;
   display: inline-block;
   /* Nudge icons slightly upward for visual centering with text. Edit --header-icon-nudge in styles.css to fine-tune. */
   transform: translate(var(--header-icon-offset-x), var(--header-icon-nudge));

}

.site-header {
    background-color: var(--color-primary);
}

.site-nav {
    max-width: 72rem;
    gap: 0.75rem;
}

.site-brand {
    letter-spacing: 0 !important;
}

#rankingNavLinks {
    flex-wrap: wrap;
    justify-content: flex-end;
}

#rankingNavLinks > a,
.site-nav-link {
    display: inline-flex !important;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.25rem;
    padding: 0.5rem 0.65rem !important;
    border: 1px solid transparent;
    border-radius: var(--radius-md) !important;
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

#rankingNavLinks > a:hover,
.site-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.14) !important;
    border-color: rgba(255, 255, 255, 0.12);
}

#navLoginLink,
.site-nav-login {
    background-color: rgba(255, 255, 255, 0.13) !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
}

#rankingNavLinks > a svg,
.site-nav-link svg {
    flex: 0 0 auto;
    margin-right: 0 !important;
}

.navbar-inner,
#main-content > section,
.max-w-4xl > section > .bg-white,
.max-w-4xl > section > .bg-gradient-to-br {
    backdrop-filter: blur(10px);
}

.home-hero,
.home-panel,
.home-cta {
    border-radius: 0.75rem;
}

.home-hero {
    background: #fff;
    border: 1px solid #e5d7d5;
    padding: 1rem 1rem 1.1rem;
}

.home-hero h1 {
    letter-spacing: -0.03em !important;
}

.home-panel {
    border-radius: 2px;
}

.home-cta {
    border-radius: 2px;
}

.max-w-4xl > section > .bg-white,
.max-w-4xl > section > .bg-gradient-to-br,
.max-w-4xl > section > .text-center {
    border-color: rgba(153, 27, 27, 0.12);
}

.max-w-4xl > section > .text-center {
    background: #fff;
    border: 1px solid #e5d7d5;
    border-radius: 2px;
    padding-left: 1rem;
    padding-right: 1rem;
}

.max-w-4xl > section > .text-center h1 {
    letter-spacing: -0.04em !important;
}

.max-w-4xl > section > .text-center p {
    max-width: 60ch;
    margin-left: auto;
    margin-right: auto;
}

.max-w-4xl .bg-white,
.max-w-4xl .bg-slate-50 {
    border: 1px solid #e5d7d5;
}

#countdown-container {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(40, 40, 40, 0.95) 0%, rgba(30, 30, 30, 0.98) 100%);
    border: 1px solid #555;
}

#countdown-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top right, rgba(239, 68, 68, 0.12), transparent 40%),
        radial-gradient(circle at bottom left, rgba(255, 255, 255, 0.04), transparent 35%);
    pointer-events: none;
}

#countdown-container > * {
    position: relative;
    z-index: 1;
}

#countdown-container .countdown-unit {
    min-width: 4.75rem;
    padding: 0.8rem 0.85rem;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(2px);
}

#countdown-container .countdown-num {
    line-height: 1;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

#countdown-container .countdown-sep {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.34);
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1;
}

#next-date-label {
    color: rgba(254, 226, 226, 0.95);
}

@media (min-width: 640px) and (max-width: 1120px) {
    #rankingNavLinks {
        width: 100% !important;
        justify-content: flex-start;
        gap: 0.35rem !important;
        margin-top: 0.35rem !important;
        padding-top: 0.6rem !important;
        border-top: 1px solid rgba(255, 255, 255, 0.16) !important;
    }
}

@media (max-width: 639px) {
    #rankingNavLinks > a,
    .site-nav-link {
        width: 100%;
        justify-content: flex-start;
        min-height: 2.6rem;
    }
}

/* PNG visual helper: remove white background appearance by blending
     Note: this is a visual workaround. For perfect transparency, supply an actual transparent PNG. */
.png-transparent {
    background: transparent !important;
    display: inline-block;
    -webkit-font-smoothing: antialiased;
    /* Multiply makes white pixels become transparent over lighter backgrounds */
    mix-blend-mode: multiply;
}

@supports not (mix-blend-mode: multiply) {
    .png-transparent { mix-blend-mode: normal; }
}

/* Navbar spacing consistency across all pages */
.navbar-inner {
  max-width: 60rem;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-left: 1rem;
  padding-right: 1rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

/* --- THE NAV HOVER GLITCH FIX --- */
.nav-link-hover {
    border-radius: var(--radius-md) !important; /* Locks the shape to match other buttons */
    transition: background-color 0.2s ease !important; /* STRICTLY animates color, never the shape */
}

.nav-link-hover:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

/* Fix for the hover state on the search result names */
.hover\:text-blue-600:hover {
    color: var(--color-accent) !important;
}

/* Ensure the dynamically injected cards obey your variables */
.rounded-3xl { 
    border-radius: calc(var(--radius-lg) + 8px) !important; 
}

/* If the "Term 2" badge is too round, override rounded-full 
   OR change the HTML class to rounded-lg */
.rounded-full { 
    border-radius: var(--radius-md) !important; 
}

/* Specifically target the cards created by the addCard function */
#analytics-summary div, 
#analytics-highlights div,
.bg-white.rounded-3xl {
    border-radius: calc(var(--radius-lg) + 4px) !important;
}
