/* ============================================================
   The UAE Admissions Clock — single-screen panel
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #08090c;
  --bg-2: #0c0e13;
  --panel: rgba(255, 255, 255, 0.028);
  --panel-2: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
  --border-bright: rgba(255, 255, 255, 0.16);
  --text: #f3f4f7;
  --muted: #8c909b;
  --faint: #595e6a;
  --accent: #3f83f8;
  --accent-2: #2dd4bf;
  --accent-soft: rgba(63, 131, 248, 0.14);
  --red: #f8716e;
  --shadow: rgba(0, 0, 0, 0.5);
  --radius: 16px;
  --radius-sm: 11px;

  --gap: clamp(10px, 1.4vw, 18px);
  --pad: clamp(14px, 1.8vw, 24px);
}

[data-theme='day'] {
  color-scheme: light;
  --bg: #f5f6f9;
  --bg-2: #eef0f4;
  --panel: #ffffff;
  --panel-2: #ffffff;
  --border: rgba(13, 18, 28, 0.1);
  --border-bright: rgba(13, 18, 28, 0.2);
  --text: #0e1116;
  --muted: #5a606d;
  --faint: #99a0ad;
  --accent: #2563eb;
  --accent-2: #0d9488;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --red: #dc2626;
  --shadow: rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overscroll-behavior: none;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

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

strong {
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.aurora {
  position: fixed;
  inset:
    calc(env(safe-area-inset-top) * -1)
    calc(env(safe-area-inset-right) * -1)
    calc(env(safe-area-inset-bottom) * -1)
    calc(env(safe-area-inset-left) * -1);
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 55% at 12% 0%, rgba(63, 131, 248, 0.16), transparent 70%),
    radial-gradient(50% 50% at 100% 100%, rgba(45, 212, 191, 0.1), transparent 70%);
  opacity: 0.9;
}

[data-theme='day'] .aurora {
  opacity: 0.5;
}

/* ---------- App shell: exactly one viewport ---------- */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100svh;
  background: var(--bg);
  padding: clamp(10px, 1.6vw, 20px);
  gap: var(--gap);
}

@supports (padding: max(0px)) {
  .app {
    padding:
      max(clamp(10px, 1.6vw, 20px), env(safe-area-inset-top))
      max(clamp(10px, 1.6vw, 20px), env(safe-area-inset-right))
      max(clamp(10px, 1.6vw, 20px), env(safe-area-inset-bottom))
      max(clamp(10px, 1.6vw, 20px), env(safe-area-inset-left));
  }
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.6rem, 0.72vw, 0.72rem);
  font-weight: 720;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

/* ---------- Top bar ---------- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: clamp(48px, 6vh, 60px);
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  backdrop-filter: blur(14px);
}

.topbar-date {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-name {
  font-weight: 680;
  font-size: clamp(0.85rem, 1vw, 1rem);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


.menu-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  transition: border-color 0.16s ease;
}

.menu-btn span {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}

.menu-btn:hover {
  border-color: var(--border-bright);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 560;
  white-space: nowrap;
  transition: border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.pill:hover {
  border-color: var(--border-bright);
  color: var(--text);
  transform: translateY(-1px);
}

/* Dark = ring with a filled core; Day = ring only. */
.theme-icon {
  position: relative;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  color: var(--muted);
}

.theme-icon::after {
  content: "";
  position: absolute;
  inset: 2.5px;
  border-radius: 50%;
  background: currentColor;
}

[data-theme='day'] .theme-icon::after {
  display: none;
}

.pill:hover .theme-icon {
  color: var(--text);
}

.theme-toggle {
  min-width: 88px;
  justify-content: center;
}

.enrolia-link {
  color: var(--text);
}

.enrolia-link-icon {
  width: 15px;
  height: 15px;
  color: var(--accent);
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.enrolia-link-text {
  color: inherit;
}

.enrolia-link:hover .enrolia-link-icon {
  color: var(--accent);
}

/* ---------- Stage ---------- */
.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.stage-head {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1.3fr 2fr;
  gap: var(--gap);
  align-items: center;
}

.accent-eyebrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.stage-head .segments {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 100%;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.5);
  animation: pulse 1.9s ease-out infinite;
}

/* Segmented control */
.segments {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel);
}

.segments button {
  padding: 7px clamp(10px, 1.4vw, 18px);
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: clamp(0.76rem, 0.9vw, 0.88rem);
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease;
}

.segments button:hover {
  color: var(--text);
}

.segments button[aria-checked='true'] {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px -8px var(--accent);
}

[data-theme='day'] .segments button[aria-checked='true'] {
  color: #fff;
}

/* ---------- Grid: clock + stats ---------- */
.grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  grid-template-rows: repeat(2, minmax(150px, 232px));
  align-content: center;
  gap: var(--gap);
}

.panel {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 20px 50px -34px var(--shadow);
  transition: border-color 0.18s ease;
}

.panel:hover {
  border-color: var(--border-bright);
}

.clock-panel {
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(14px, 2.2vh, 28px);
  padding: var(--pad);
  background:
    linear-gradient(180deg, rgba(63, 131, 248, 0.06), transparent 55%),
    var(--panel);
}

.clock-head {
  flex: 0 0 auto;
  color: var(--muted);
}

/* Countdown */
.countdown {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(8px, 1vw, 14px);
  height: clamp(132px, 24vh, 210px);
  min-height: 0;
}

.cd-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 0.8vw, 9px);
  min-width: 0;
  padding: clamp(6px, 1vw, 12px) 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}

.cd-num {
  font-size: clamp(2.2rem, 5.4vw, 6rem);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.cd-unit.is-seconds .cd-num {
  color: var(--accent);
}

.cd-label {
  color: var(--faint);
  font-size: clamp(0.56rem, 0.7vw, 0.7rem);
  font-weight: 680;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Progress */
.progress-block {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.progress-figures {
  font-size: clamp(0.95rem, 1.2vw, 1.25rem);
  font-weight: 760;
  letter-spacing: -0.01em;
}

.progress-figures em {
  color: var(--muted);
  font-style: normal;
  font-weight: 600;
  font-size: 0.85em;
}

.bar {
  position: relative;
  height: 9px;
  border-radius: 999px;
  background: rgba(127, 127, 140, 0.16);
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 16px -2px var(--accent);
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Stat cards */
.stat {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: clamp(4px, 0.7vw, 9px);
  min-width: 0;
  padding: var(--pad);
}

.stat .stat-num {
  margin-top: auto;
}

.stat-num {
  font-size: clamp(1.5rem, 2.5vw, 2.7rem);
  font-weight: 780;
  line-height: 0.98;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.72rem, 0.85vw, 0.86rem);
  line-height: 1.35;
}

.stat-marketing {
  background:
    linear-gradient(180deg, rgba(45, 212, 191, 0.07), transparent 60%),
    var(--panel);
}

.live-amount {
  color: var(--accent-2);
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

/* Full running numbers (revenue / marketing) need a tighter size to fit. */
.stat-num.running {
  font-size: clamp(1.25rem, 1.9vw, 2.05rem);
}

/* Live "+1 incoming" indicator on the admissions card. */
.next-adm {
  position: absolute;
  top: var(--pad);
  right: var(--pad);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 760;
  animation: nextPulse 2.4s ease-in-out infinite;
}

@keyframes nextPulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.next-ring {
  width: 20px;
  height: 20px;
  transform: rotate(-90deg);
}

.next-ring-bg {
  fill: none;
  stroke: rgba(127, 127, 140, 0.28);
  stroke-width: 2.6;
}

.next-ring-fg {
  fill: none;
  stroke: var(--red);
  stroke-width: 2.6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s linear;
}

.next-adm-label {
  letter-spacing: 0.02em;
}

.stat-admissions .eyebrow,
.stat-revenue .eyebrow {
  padding-right: 42px;
}

/* ---------- Dock: ticker + actions ---------- */
.dock {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--gap);
  height: clamp(48px, 6.4vh, 62px);
  padding: 0 4px 0 clamp(12px, 1.6vw, 20px);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}

.ticker {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}

.ticker-track {
  display: inline-flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
  will-change: transform;
  animation: marquee 46s linear infinite;
}

.ticker:hover .ticker-track {
  animation-play-state: paused;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.ticker-item::after {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin: 0 clamp(14px, 1.6vw, 24px);
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.55;
}

.dock-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 clamp(12px, 1.4vw, 18px);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 0.86rem;
  font-weight: 640;
  white-space: nowrap;
  transition: border-color 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

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

.btn.ghost {
  background: var(--panel-2);
  color: var(--text);
}

.btn.ghost:hover {
  border-color: var(--border-bright);
}

.btn.primary {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 26px -12px var(--accent);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: clamp(78px, 12vh, 110px);
  z-index: 60;
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 16px;
  border: 1px solid var(--border-bright);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 560;
  box-shadow: 0 16px 40px -16px var(--shadow);
}

.toast[hidden] {
  display: none;
}

/* ---------- Overlays (menu + modal) ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(4, 5, 8, 0.62);
  backdrop-filter: blur(6px);
}

.overlay[hidden] {
  display: none;
}

.overlay-center {
  display: grid;
  place-items: center;
  padding: 20px;
}

.drawer {
  position: absolute;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(360px, 88vw);
  height: 100%;
  padding: clamp(16px, 3vw, 26px);
  border-right: 1px solid var(--border-bright);
  background: var(--bg-2);
  box-shadow: 24px 0 80px -30px #000;
  animation: slideIn 0.22s ease;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drawer-links a,
.drawer-links button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-weight: 560;
  text-align: left;
  transition: background 0.14s ease;
}

.drawer-links a span,
.drawer-links button span {
  color: var(--faint);
}

.drawer-links a:hover,
.drawer-links button:hover {
  background: var(--panel-2);
}

.drawer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

.drawer-foot {
  margin: 0;
  color: var(--faint);
  font-size: 0.78rem;
  line-height: 1.45;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  font-size: 1.3rem;
  line-height: 1;
}

.icon-btn:hover {
  border-color: var(--border-bright);
}

.modal {
  width: min(560px, 100%);
  max-height: 84vh;
  overflow-y: auto;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  background: var(--bg-2);
  box-shadow: 0 30px 90px -30px #000;
  animation: popIn 0.2s ease;
}

.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}

.modal-head h2 {
  margin: 4px 0 0;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
}

.modal-body {
  padding: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.modal-body p {
  margin: 0 0 14px;
}

.modal-body strong {
  color: var(--text);
}

.modal-note {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  font-size: 0.86rem;
}

/* ---------- Animations ---------- */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.5);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(45, 212, 191, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(45, 212, 191, 0);
  }
}

@keyframes marquee {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

@keyframes slideIn {
  from {
    transform: translateX(-12px);
    opacity: 0;
  }
}

@keyframes popIn {
  from {
    transform: scale(0.97);
    opacity: 0;
  }
}

/* ============================================================
   Responsive
   ============================================================ */

/* Tablet: stats become a 2x2 under the clock */
@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr 1fr;
  }

  .clock-panel {
    grid-row: 1 / 2;
    grid-column: 1 / 3;
  }

  /* Stack the head so the segment toggle spans the full grid width
     instead of overflowing past a single column. */
  .stage-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .accent-eyebrow {
    justify-self: auto;
  }

  .stage-head .segments,
  .segments {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

  .segments button {
    padding: 8px 4px;
    text-align: center;
  }
}

/* Mobile: single screen, stacked */
@media (max-width: 620px) {
  .app {
    padding: 8px;
    gap: 8px;
  }

  .brand-name {
    font-size: 0.92rem;
  }

  .topbar-date {
    display: none;
  }

  .theme-toggle {
    min-width: 84px;
  }

  .enrolia-link {
    display: inline-grid;
    place-items: center;
    flex: 0 0 38px;
    height: 38px;
    width: 38px;
    padding: 0;
    gap: 0;
  }

  .enrolia-link-text {
    display: none;
  }

  .enrolia-link-icon {
    width: 16px;
    height: 16px;
  }

  .accent-eyebrow {
    justify-content: center;
    text-align: center;
  }

  .stage-head {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .segments {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

  .segments button {
    padding: 8px 4px;
    text-align: center;
  }

  .grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows:
      minmax(118px, 1.35fr)
      minmax(68px, 0.9fr)
      minmax(84px, 1fr)
      minmax(68px, 0.9fr);
    gap: 8px;
  }

  .clock-panel {
    grid-column: 1 / 3;
    grid-row: 1;
    gap: 10px;
  }

  .stat-marketing {
    grid-column: 1 / 3;
    grid-row: 2;
  }

  .stat-admissions {
    grid-column: 1;
    grid-row: 3;
  }

  .stat-institutions {
    grid-column: 2;
    grid-row: 3;
  }

  .stat-revenue {
    grid-column: 1 / 3;
    grid-row: 4;
  }

  .countdown {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    height: auto;
    flex: 1 1 auto;
  }

  .cd-num {
    font-size: clamp(1.4rem, 8.5vw, 2.4rem);
  }

  .cd-label {
    font-size: 0.5rem;
    letter-spacing: 0.07em;
  }

  .stat {
    padding: 12px 14px;
  }

  .stat-num {
    font-size: clamp(1.3rem, 6vw, 1.8rem);
  }

  .stat-num.running {
    font-size: clamp(1.2rem, 5.4vw, 1.6rem);
  }

  /* On the half-width tiles the numbers can be a touch smaller. */
  .stat-admissions .stat-num,
  .stat-institutions .stat-num {
    font-size: clamp(1.3rem, 7vw, 1.9rem);
  }

  .dock {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    gap: 8px;
    padding: 8px;
  }

  .ticker {
    width: 100%;
  }

  .ticker-track {
    animation-duration: 32s;
  }

  .dock-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .btn {
    height: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
