/* =========================================================================
   dimalearn countdown :: styles.css
   "Casbah Azure" system. Tokens flip on html[data-theme]. Never pure black/white.
   No pills, no glassmorphism/backdrop-blur, no accent side-stripe borders,
   no gradient text. Motion is transform/opacity only and reduced-motion gated.
   Fully responsive: fluid type/space via clamp(), square countdown cells via
   flex + aspect-ratio (never overflow), capped sections for ultra-wide.
   ========================================================================= */

/* TimeBurner, wordmark ONLY. Files live in fonts/ at the repo root. */
@font-face {
  font-family: "TimeBurner";
  src: url("fonts/TimeBurner-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "TimeBurner";
  src: url("fonts/TimeBurner-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

/* ----------------------------- Design tokens ----------------------------- */
:root {
  /* Easing: ease-out-quint. Decelerating, no overshoot, calm/premium feel. */
  --ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);
  /* Azure is the constant brand anchor across both themes. */
  --accent: #2c6fb2;
  /* Single source of truth for the centered content width (header/hero/footer). */
  --maxw: 1320px;
}

/* DARK (default) */
html[data-theme="dark"] {
  --bg: linear-gradient(180deg, #163a63 0%, #102a49 55%, #0a1b30 100%);
  /* Two soft radial glows layered over the gradient (see .bg-layer). */
  --glow-1: radial-gradient(60% 50% at 12% 8%, rgba(44, 111, 178, 0.22), transparent 70%);
  --glow-2: radial-gradient(55% 45% at 90% 4%, rgba(22, 58, 99, 0.35), transparent 72%);

  --cell-surface: linear-gradient(180deg, #222a33, #161c24);
  --cell-border: #2a323a;
  --cell-radius: clamp(12px, 2.2vw, 18px);
  --cell-shadow: 0 12px 24px rgba(0, 0, 0, 0.27);

  --field: #181d22;
  --switcher: #232a30;
  --border: #2a323a;

  --text: #eceef0;
  --text-2: #b9bfc5;
  --muted: #8e969e;
  --footer-muted: #8e969e; /* 6.5:1 on the dark ground (AA); #636c75 failed */

  --accent-text: #88b4e4; /* eyebrow + colons */
  --on-accent: #fbf6ec; /* text on azure fill */

  --wordmark: #eceef0;
}

/* LIGHT */
html[data-theme="light"] {
  --bg: linear-gradient(180deg, #fbf6ec, #f5eddb);
  --glow-1: radial-gradient(60% 50% at 12% 8%, rgba(44, 111, 178, 0.1), transparent 70%);
  --glow-2: radial-gradient(55% 45% at 90% 4%, rgba(44, 111, 178, 0.07), transparent 72%);

  /* Spec table says #FFFFFF for cards/field; the global rule forbids pure white.
     #FEFDFB is an imperceptible warm-white that satisfies both. */
  --cell-surface: #fefdfb;
  --cell-border: #d8dcdf;
  --cell-radius: clamp(12px, 2.2vw, 18px);
  --cell-shadow: 0 8px 16px rgba(26, 27, 30, 0.08);

  --field: #fefdfb;
  --switcher: rgba(26, 27, 30, 0.03);
  --border: #d8dcdf;

  --text: #1a1b1e;
  --text-2: #49525a;
  --muted: #6b7178;
  --footer-muted: #6b7178; /* ~4.9:1 on cream (AA) */

  --accent-text: #1e5187; /* darker azure clears AAA on cream */
  --on-accent: #fbf6ec;

  --wordmark: #17120d;
}

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

html {
  -webkit-text-size-adjust: 100%; /* stop iOS bumping font sizes in landscape */
}

body {
  min-height: 100vh;
  min-height: 100dvh; /* dvh accounts for mobile browser chrome */
  font-family: "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background-color: #0a1b30; /* non-pure paint before the layer resolves */
  overflow-x: hidden; /* contract: no horizontal scroll at any breakpoint */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html[data-theme="light"] body {
  background-color: #fbf6ec;
}

/* Background + glows on a fixed full-viewport layer.
   WHY not background-attachment:fixed: that is buggy/janky on iOS Safari. A
   position:fixed layer keeps the glow static across scroll on every browser. */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--glow-1), var(--glow-2), var(--bg);
  pointer-events: none;
}

/* Arabic body text uses Cairo. The wordmark keeps TimeBurner regardless. */
html[lang="ar"] body {
  font-family: "Cairo", system-ui, sans-serif;
}

/* --------------------------- Shared utilities --------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* Visible keyboard focus everywhere. Azure ring with offset so it never hugs the glyph. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ------------------------------- Layout --------------------------------- */
.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Header / hero / footer share one centered max-width so content never hugs
   the extreme edges on ultra-wide displays while the background stays full-bleed. */
.site-header,
.site-footer {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap; /* safety valve below ~340px: controls drop to a second row */
  /* Vertical padding tracks viewport height so header/footer shrink on short
     desktops, helping the whole page fit one screen (footer stays visible). */
  padding: clamp(12px, 2.2vh, 24px) clamp(18px, 4vw, 28px);
}

/* HEADER */
.wordmark {
  font-family: "TimeBurner", "Lexend", sans-serif;
  font-weight: 700;
  font-size: clamp(21px, 5vw, 24px);
  line-height: 1;
  color: var(--wordmark);
}

.header-right {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.6vw, 18px);
}

/* Language switcher: segmented control (rectangular, soft radius, not a pill). */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--switcher);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.lang-btn {
  min-width: 42px;
  min-height: 40px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: color 0.18s var(--ease-out-quint), background-color 0.18s var(--ease-out-quint);
}

.lang-btn:hover {
  color: var(--text-2);
}

.lang-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

/* Theme toggle: icon button, 44px tap target. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--switcher);
  color: var(--text-2);
  transition: color 0.18s var(--ease-out-quint), transform 0.18s var(--ease-out-quint);
}

.theme-toggle:hover {
  color: var(--text);
  transform: translateY(-1px);
}

/* Icon visibility is theme-driven: moon in dark, sun in light. */
.theme-toggle .icon-sun {
  display: none;
}
html[data-theme="light"] .theme-toggle .icon-moon {
  display: none;
}
html[data-theme="light"] .theme-toggle .icon-sun {
  display: inline-block;
}

/* Tighten the switcher on small phones so the header fits one row to ~340px. */
@media (max-width: 480px) {
  .lang-btn {
    min-width: 38px;
    padding: 6px 8px;
  }
}

/* MAIN / HERO */
.hero {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* vh-based rhythm: compresses on short desktops so the hero + footer fit one
     screen, expands on tall ones. Mobile (tall) lands near the max, unchanged. */
  gap: clamp(18px, 3vh, 40px);
  padding: clamp(16px, 3vh, 44px) clamp(20px, 5vw, 40px);
  text-align: center;
}

.eyebrow {
  font-weight: 700;
  font-size: clamp(10px, 1.4vw, 11px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-text);
}

/* Arabic letterforms connect: tracking + uppercase mangle them. Neutralize. */
html[lang="ar"] .eyebrow,
html[lang="ar"] .label {
  letter-spacing: 0;
  text-transform: none;
}

/* Arabic eyebrow (قريبًا): connected script needs more size than tracked Latin caps. */
html[lang="ar"] .eyebrow {
  font-size: clamp(15px, 2.4vw, 17px);
}

.headline {
  font-weight: 700;
  /* min() caps the width-driven size by viewport height so a short desktop
     shrinks the title instead of pushing the footer off-screen. */
  font-size: min(clamp(30px, 6vw, 60px), 8.5vh);
  letter-spacing: -0.03em;
  line-height: 1.06;
  color: var(--text);
  max-width: 820px; /* matches the pen: ~2 lines on desktop, wraps fluidly below */
  text-wrap: balance; /* even line lengths where supported */
}
/* Negative tracking is too tight for Arabic shaping; relax it. */
html[lang="ar"] .headline {
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.sub {
  font-weight: 300;
  font-size: clamp(15px, 1.6vw, 18px);
  line-height: 1.55;
  color: var(--text-2);
  max-width: 54ch;
  text-wrap: pretty;
}
/* Readex Pro 300 is unavailable; 400 keeps Arabic legible. */
html[lang="ar"] .sub {
  font-weight: 400;
}

/* COUNTDOWN ---------------------------------------------------------------
   Cells are flex:1 squares (aspect-ratio) capped at 150px. They divide the row
   evenly and shrink with the viewport, so the clock NEVER overflows. The row is
   width-capped so cells reach their 150px design size on desktop and no more. */
.countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.4vw, 14px);
  width: 100%;
  max-width: 720px;
  /* A clock is read left-to-right even in RTL; keep D:H:M:S order. */
  direction: ltr;
}

.cell {
  flex: 1 1 0;
  min-width: 0;
  /* Cap by both 150px (design size) and 18vh (so cells shrink on short desktops). */
  max-width: min(150px, 18vh);
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(2px, 0.8vw, 6px);
  background: var(--cell-surface);
  border: 1px solid var(--cell-border);
  border-radius: var(--cell-radius);
  box-shadow: var(--cell-shadow);
}

.num {
  font-weight: 700;
  /* Tracks cell width (8vw ~= viewport/4) and is capped by 7.2vh so the digit
     always fits inside the height-shrunk cell on short desktops. */
  font-size: min(clamp(24px, 8vw, 56px), 7.2vh);
  line-height: 1;
  color: var(--text);
  /* tabular-nums: fixed-width digits so the clock does not jitter each tick. */
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.label {
  font-weight: 600;
  font-size: clamp(8px, 1.6vw, 11px);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
}

.colon {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: clamp(24px, 4.5vw, 46px);
  line-height: 1;
  color: var(--accent-text);
  /* Optical lift: align the colon with the number row, not the labels below. */
  transform: translateY(-0.16em);
}

/* On phones the colons are dropped so the four cells get all the width. */
@media (max-width: 480px) {
  .colon {
    display: none;
  }
  .countdown {
    gap: 8px;
  }
}

/* CTA */
.cta {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 460px;
  padding: 6px 6px 6px 18px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color 0.18s var(--ease-out-quint);
}

/* Logical padding so the icon stays on the leading edge in RTL. */
html[dir="rtl"] .cta {
  padding: 6px 18px 6px 6px;
}

.cta:focus-within {
  border-color: var(--accent);
}

.cta-icon {
  flex: 0 0 auto;
  color: var(--muted);
}

.cta-input {
  flex: 1;
  min-width: 0; /* allow shrink inside flex without overflow */
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-weight: 500;
  font-size: 16px; /* >=16px stops iOS auto-zoom on focus */
}

.cta-input::placeholder {
  color: var(--muted);
  opacity: 1; /* normalize Firefox placeholder dimming */
}

.cta-input:focus {
  outline: none; /* ring lives on .cta via :focus-within, avoids double outline */
}

.cta-btn {
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  padding: 12px 22px;
  background: var(--accent);
  color: var(--on-accent);
  /* 19px bold is load-bearing for contrast: cream-on-azure 4.85:1 clears
     WCAG AAA for large text (>=18.66px bold). Do not shrink below this. */
  font-weight: 700;
  font-size: 19px;
  line-height: 1;
  transition: transform 0.18s var(--ease-out-quint), opacity 0.18s var(--ease-out-quint);
}

.cta-btn:hover {
  transform: translateY(-1px);
  opacity: 0.94;
}

.cta-btn:active {
  transform: translateY(0);
}

.cta-thanks {
  font-weight: 500;
  font-size: 15px;
  color: var(--accent-text);
}

/* Stack the CTA on narrow screens so the button keeps its 44px+ height. */
@media (max-width: 480px) {
  .cta {
    flex-wrap: wrap;
    padding: 12px;
    gap: 10px;
  }
  .cta-icon {
    order: 1;
  }
  .cta-input {
    flex: 1 1 auto;
    order: 2;
    padding-block: 6px;
  }
  .cta-btn {
    flex: 1 1 100%;
    order: 3;
    padding: 14px 22px;
  }
}

/* FOOTER */
.copyright {
  font-weight: 500;
  font-size: 13px;
  color: var(--footer-muted);
}

.socials {
  display: flex;
  align-items: center;
  gap: 4px;
}

.socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; /* full tap target around an 18px glyph */
  height: 44px;
  color: var(--muted);
  border-radius: 10px;
  transition: color 0.18s var(--ease-out-quint), transform 0.18s var(--ease-out-quint);
}

.socials a:hover {
  color: var(--text);
  transform: translateY(-1px);
}

/* ------------------------------- Motion --------------------------------- */
/* Gentle hero entrance: fade + small upward translate, staggered. transform/opacity
   only (never layout). Entirely disabled under reduced-motion below. */
@keyframes hero-rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.eyebrow,
.headline,
.sub,
.countdown,
.cta {
  animation: hero-rise 0.7s var(--ease-out-quint) both;
}
.headline {
  animation-delay: 0.06s;
}
.sub {
  animation-delay: 0.12s;
}
.countdown {
  animation-delay: 0.18s;
}
.cta {
  animation-delay: 0.24s;
}

/* Respect reduced motion: kill ALL entrance and hover transforms. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .cta-btn:hover,
  .theme-toggle:hover,
  .socials a:hover {
    transform: none;
  }
}
