/**
 * Kiosk UI — branding via CSS variables (edit :root below).
 * Logo: place PNG/SVG at static/logo.png (URL path is usually /logo.png).
 *
 * STC Forward: place files under static/fonts/ — names must match below (.ttf or .woff2).
 * If the URL 404s, the browser uses Tahoma / system UI.
 */

@font-face {
  font-family: "STC Forward";
  src:
    local("STC Forward"),
    url("../fonts/STCForward-Regular.ttf") format("truetype"),
    url("../fonts/STCForward-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "STC Forward";
  src:
    local("STC Forward Bold"),
    url("../fonts/STCForward-Bold.ttf") format("truetype"),
    url("../fonts/STCForward-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Brand — adjust for your event */
  --brand-primary: #0c4a6e;
  --brand-primary-light: #155e8c;
  --brand-accent: #0ea5e9;
  --brand-accent-soft: rgba(14, 165, 233, 0.22);
  --brand-secondary: #0369a1;
  --brand-gold: #d4a853;

  /* Surfaces */
  --bg-deep: #041a2c;
  --bg-mid: #0a2744;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-elevated: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.14);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);

  /* Text */
  --text: #f0f7fc;
  --text-muted: rgba(240, 247, 252, 0.72);
  --text-subtle: rgba(240, 247, 252, 0.52);

  /* Status */
  --success: #4ade80;
  --error: #fca5a5;
  --focus-ring: rgba(14, 165, 233, 0.45);

  /* Touch */
  --touch-min: 56px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --step-transition: 280ms ease;

  /* Typography — STC Forward when font files exist in static/fonts/ */
  --font-kiosk: "STC Forward", "Tahoma", "Segoe UI", "Noto Sans Arabic", system-ui, sans-serif;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body.kiosk-body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font-kiosk);
  color: var(--text);
  background: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(14, 165, 233, 0.15), transparent),
    linear-gradient(165deg, var(--bg-deep) 0%, var(--bg-mid) 55%, #061a2e 100%);
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
  -webkit-font-smoothing: antialiased;
}

.kiosk-shell {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 28px);
}

/* Header / branding */
.kiosk-brand {
  text-align: center;
  margin-bottom: clamp(16px, 4vw, 28px);
  animation: fade-in 0.45s ease;
}

.brand-logo-wrap {
  position: relative;
  width: min(160px, 38vw);
  height: min(160px, 38vw);
  margin: 0 auto 12px;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.35));
}

.brand-logo.is-hidden {
  display: none;
}

.logo-fallback {
  width: 100%;
  height: 100%;
  border-radius: 24px;
  background: linear-gradient(145deg, var(--brand-primary), var(--brand-secondary));
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.logo-fallback[hidden] {
  display: none !important;
}

.logo-fallback-icon {
  width: 48%;
  height: 48%;
  opacity: 0.9;
}

.kiosk-title {
  margin: 0;
  font-size: clamp(1.35rem, 4.2vw, 1.85rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.25;
  color: var(--text);
}

.kiosk-subtitle {
  margin: 8px 0 0;
  font-size: clamp(0.95rem, 2.8vw, 1.05rem);
  color: var(--text-muted);
  line-height: 1.55;
  max-width: 36em;
  margin-inline: auto;
}

.kiosk-title-stack {
  margin: 0;
  font-weight: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.kiosk-title--line {
  display: block;
  width: 100%;
}

.kiosk-title--line-en {
  font-size: clamp(1.05rem, 3.2vw, 1.45rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.88);
}

.kiosk-subtitle-stack {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 38em;
  margin-inline: auto;
}

.kiosk-subtitle-stack .kiosk-subtitle {
  margin: 0;
}

.kiosk-subtitle--en {
  font-size: clamp(0.88rem, 2.5vw, 0.98rem);
  opacity: 0.92;
}

/* Bilingual blocks (language screen): stacked lines, centered */
.stack-bilingual {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  margin-bottom: 12px;
}

.stack-bilingual .panel-title,
.stack-bilingual .panel-lead {
  margin: 0;
}

.stack-bilingual .line-ar,
.stack-bilingual .line-en {
  margin: 0;
  width: 100%;
  max-width: 28em;
}

.stack-bilingual .line-en {
  font-size: 0.95em;
  font-weight: 700;
  color: var(--text-muted);
}

.stack-bilingual.lang-instruct .line-en {
  font-weight: 600;
  font-size: 0.98rem;
}

html[dir="ltr"] .stack-bilingual .line-ar,
html[dir="ltr"] .stack-bilingual .line-en {
  text-align: center;
}

/* Progress */
.progress-wrap {
  margin-bottom: 18px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.88rem;
  color: var(--text-subtle);
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 25%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-accent), var(--brand-gold));
  transition: width var(--step-transition);
}

.progress-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: transform var(--step-transition), background var(--step-transition);
}

.progress-dot.is-active {
  background: var(--brand-accent);
  transform: scale(1.25);
  box-shadow: 0 0 0 4px var(--brand-accent-soft);
}

.progress-dot.is-done {
  background: var(--brand-gold);
  opacity: 0.85;
}

/* Panels */
.kiosk-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(18px, 4vw, 26px);
  box-shadow: var(--shadow);
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--step-transition), transform var(--step-transition);
}

.panel[hidden] {
  display: none !important;
}

.panel.is-entering {
  animation: panel-in 0.35s ease;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.panel-lead {
  margin: 0 0 14px;
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.panel-title {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 800;
}

label {
  display: block;
  margin: 14px 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field-hint {
  font-size: 0.82rem;
  color: var(--text-subtle);
  margin-top: 4px;
}

input,
select {
  width: 100%;
  min-height: var(--touch-min);
  padding: 12px 14px;
  font-size: 1.08rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-family: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input.field-error {
  border-color: rgba(248, 113, 113, 0.7);
}

.row {
  margin-bottom: 2px;
}

/* Buttons */
.btn {
  width: 100%;
  min-height: calc(var(--touch-min) + 6px);
  margin-top: 16px;
  padding: 14px 18px;
  font-size: 1.12rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  font-weight: 800;
  font-family: inherit;
  background: linear-gradient(135deg, var(--brand-accent), var(--brand-secondary));
  color: #fff;
  box-shadow: 0 10px 28px rgba(14, 165, 233, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.ghost {
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 700;
  box-shadow: none;
}

.btn.ghost:active:not(:disabled) {
  transform: scale(0.99);
}

.bar {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.bar .btn {
  margin-top: 0;
  flex: 1;
}

.types {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.type-btn {
  text-align: right;
  min-height: calc(var(--touch-min) + 10px);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-size: 1.08rem;
  cursor: pointer;
  touch-action: manipulation;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.type-btn:hover {
  border-color: rgba(14, 165, 233, 0.45);
}

.type-btn.is-selected {
  border-color: var(--brand-accent);
  background: var(--brand-accent-soft);
}

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

.type-btn small {
  display: block;
  color: var(--text-subtle);
  font-size: 0.82rem;
  margin-top: 6px;
  font-weight: 500;
}

/* Messages */
#msg {
  margin-top: 14px;
  min-height: 1.2em;
  font-size: 0.92rem;
  line-height: 1.5;
}

#msg.err {
  color: var(--error);
}

#msg.ok {
  color: var(--success);
}

.api-link {
  margin-top: 12px;
  font-size: 0.85rem;
  text-align: center;
}

.api-link a {
  color: var(--brand-accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(14, 165, 233, 0.35);
}

.api-link a:hover {
  border-bottom-color: var(--brand-accent);
}

/* Success panel */
.success-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(74, 222, 128, 0.15);
  border: 2px solid rgba(74, 222, 128, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-icon svg {
  width: 36px;
  height: 36px;
  color: var(--success);
}

.success-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 800;
  text-align: center;
}

.success-text {
  margin: 0 0 16px;
  text-align: center;
  color: var(--text-muted);
  line-height: 1.55;
}

.countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--brand-accent);
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 26, 44, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.loading-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.loading-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 36px;
  text-align: center;
  box-shadow: var(--shadow);
}

.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border: 4px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--brand-accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text-muted);
}

/* Footer */
.kiosk-footer {
  margin-top: auto;
  padding-top: clamp(20px, 5vw, 32px);
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-subtle);
  line-height: 1.5;
}

.kiosk-footer strong {
  color: var(--text-muted);
  font-weight: 700;
}

/* Language selection */
.kiosk-brand-text {
  transition: opacity 0.25s ease;
}

.lang-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}

@media (max-width: 420px) {
  .lang-row {
    grid-template-columns: 1fr;
  }
}

.btn.btn-lang-outline {
  background: transparent;
  color: var(--text);
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: none;
}

.btn.btn-lang-outline:active:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
}

/* First screen: language — hide progress/footer/technical link; keep title under logo visible */
.kiosk-shell[data-ui-step="s0"] .progress-wrap,
.kiosk-shell[data-ui-step="s0"] .kiosk-footer,
.kiosk-shell[data-ui-step="s0"] .api-link {
  display: none !important;
}

/* Credit line (English) — keep visible on language screen */
.kiosk-credit {
  margin: 10px 0 0;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-subtle);
  max-width: 42em;
  margin-inline: auto;
}

.kiosk-credit strong {
  color: var(--text-muted);
  font-weight: 600;
}

/* English / LTR layout tweaks */
html[dir="ltr"] .type-btn,
html[dir="ltr"] .panel-title,
html[dir="ltr"] .panel-lead,
html[dir="ltr"] label {
  text-align: left;
}

html[dir="ltr"] .progress-label {
  flex-direction: row-reverse;
}

html[dir="ltr"] .lang-row {
  direction: ltr;
}
