/* sms.rip — design system
   Mobile-first from 280px (fold phones), dark-first, RTL-aware.
   No external fonts, no CDN: the CSP forbids external origins entirely. */

:root {
  --bg:        #0b0f14;
  --bg-soft:   #121821;
  --bg-card:   #151c26;
  --bg-hover:  #1b2430;
  --border:    #232e3d;
  --border-lit:#2f3d50;

  --text:      #e8eef6;
  --text-dim:  #93a3b8;
  --text-mute: #64748b;

  --accent:    #22d3a5;
  --accent-lit:#4ce6bd;
  --accent-dim: rgba(34, 211, 165, 0.12);

  --warn:      #fbbf24;
  --danger:    #f87171;
  --info:      #60a5fa;

  --radius:    14px;
  --radius-sm: 10px;
  --radius-lg: 20px;

  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
  --ring:      0 0 0 3px var(--accent-dim);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "Noto Sans", "Noto Sans Arabic", "Noto Sans Devanagari", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --header-h: 60px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f8fb; --bg-soft: #ffffff; --bg-card: #ffffff; --bg-hover: #eef2f7;
    --border: #e2e8f0; --border-lit: #cbd5e1;
    --text: #0f172a; --text-dim: #475569; --text-mute: #94a3b8;
    --accent: #0d9488; --accent-lit: #14b8a6; --accent-dim: rgba(13,148,136,.10);
    --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

/* RTL: logical properties do most of the work; these are the exceptions. */
[dir="rtl"] .flip { transform: scaleX(-1); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-lit); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 1em; color: var(--text-dim); }

/* ------------------------------------------------------------------ layout */
.wrap { width: 100%; max-width: 1140px; margin-inline: auto; padding-inline: 16px; }
@media (max-width: 340px) { .wrap { padding-inline: 12px; } }

.stack   { display: grid; gap: 16px; }
.stack-sm{ display: grid; gap: 8px; }
.row     { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-tight { display: flex; gap: 8px; align-items: center; }
.spread  { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow    { flex: 1 1 auto; min-width: 0; }
.center  { text-align: center; }
.muted   { color: var(--text-mute); }
.dim     { color: var(--text-dim); }
.small   { font-size: .85rem; }
.tiny    { font-size: .78rem; }
.mono    { font-family: var(--mono); }
.nowrap  { white-space: nowrap; }
.hidden  { display: none !important; }

/* ------------------------------------------------------------------ header */
.hdr {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.hdr-in { display: flex; align-items: center; gap: 12px; height: var(--header-h); }

.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.1rem; color: var(--text); letter-spacing: -.02em;
}
.brand:hover { color: var(--text); }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
             box-shadow: 0 0 12px var(--accent); flex: none; }

.nav { display: flex; gap: 2px; margin-inline-start: auto; align-items: center; }
.nav a, .nav button {
  padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-dim);
  font-size: .9rem; font-weight: 500; background: none; border: 0; cursor: pointer;
  font-family: inherit;
}
.nav a:hover, .nav button:hover { background: var(--bg-hover); color: var(--text); }
.nav a.on { color: var(--text); background: var(--bg-hover); }

/* Mobile: primary nav collapses to a bottom bar — thumb-reachable. */
.tabbar { display: none; }
@media (max-width: 780px) {
  .nav .nav-hide { display: none; }
  .tabbar {
    display: flex; position: fixed; inset-inline: 0; bottom: 0; z-index: 60;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    flex: 1; display: grid; justify-items: center; gap: 3px;
    padding: 9px 4px; font-size: .68rem; color: var(--text-mute); min-height: 52px;
  }
  .tabbar a.on { color: var(--accent); }
  .tabbar svg { width: 21px; height: 21px; }
  main { padding-bottom: 72px; }
}

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card-pad-sm { padding: 14px; }
.card-lift { box-shadow: var(--shadow); }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (max-width: 340px) { .grid { grid-template-columns: 1fr; } }

.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1.4fr 1fr; } }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;         /* 44px = accessible touch target */
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-size: .93rem; font-weight: 600;
  cursor: pointer; text-align: center;
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #05231c; }
.btn-primary:hover:not([disabled]) { background: var(--accent-lit); color: #05231c; }
.btn-ghost   { background: var(--bg-soft); color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not([disabled]) { background: var(--bg-hover); border-color: var(--border-lit); color: var(--text); }
.btn-danger  { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover:not([disabled]) { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.btn-block   { width: 100%; }
.btn-sm      { min-height: 36px; padding: 0 12px; font-size: .85rem; }

/* ------------------------------------------------------------------ inputs */
.field { display: grid; gap: 6px; }
.label { font-size: .85rem; font-weight: 600; color: var(--text-dim); }

.input, .select {
  width: 100%; min-height: 44px; padding: 10px 13px;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 16px;            /* 16px stops iOS zoom-on-focus */
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input::placeholder { color: var(--text-mute); }

.search { position: relative; }
.search .input { padding-inline-start: 40px; }
.search svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%);
              width: 18px; height: 18px; color: var(--text-mute); pointer-events: none; }

/* ------------------------------------------------------------------ pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; letter-spacing: .01em;
  background: var(--bg-hover); color: var(--text-dim); white-space: nowrap;
}
.pill-ok    { background: var(--accent-dim); color: var(--accent); }
.pill-warn  { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.pill-danger{ background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.pill-info  { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.dot-pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ------------------------------------------------------------------ tiles */
.tile {
  display: flex; align-items: center; gap: 11px;
  padding: 12px; border-radius: var(--radius-sm);
  background: var(--bg-soft); border: 1px solid var(--border);
  cursor: pointer; text-align: start; width: 100%;
  font: inherit; color: var(--text);
  transition: border-color .15s, background .15s;
}
.tile:hover { background: var(--bg-hover); border-color: var(--border-lit); color: var(--text); }
.tile img, .tile .ico {
  width: 30px; height: 30px; border-radius: 7px; flex: none; object-fit: contain;
  background: var(--bg-hover);
}
.tile-flag img { border-radius: 3px; height: 21px; width: 30px; }
.tile .grow { display: grid; gap: 1px; }
.tile b { font-weight: 600; font-size: .92rem; }

/* ------------------------------------------------------------------ tables */
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: start; font-size: .76rem; text-transform: uppercase;
          letter-spacing: .05em; color: var(--text-mute); padding: 8px 10px; font-weight: 600; }
.tbl td { padding: 11px 10px; border-top: 1px solid var(--border); }
.tbl tr:hover td { background: var(--bg-soft); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --------------------------------------------------------------- countdown */
/* The centrepiece of the order screen: a ring that drains over the TTL. */
.countdown { display: grid; place-items: center; gap: 10px; }
.ring { position: relative; width: 168px; height: 168px; }
@media (max-width: 340px) { .ring { width: 140px; height: 140px; } }

.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.ring .track { stroke: var(--border); }
.ring .prog  { stroke: var(--accent); transition: stroke-dashoffset 1s linear, stroke .4s; }
.ring.warn .prog { stroke: var(--warn); }
.ring.crit .prog { stroke: var(--danger); }

.ring-mid {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.ring-time { font-family: var(--mono); font-size: 1.9rem; font-weight: 600; letter-spacing: -.02em;
             font-variant-numeric: tabular-nums; }
.ring.crit .ring-time { color: var(--danger); }
.ring-lbl { font-size: .72rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: .06em; }

/* -------------------------------------------------------------- the number */
.number-box {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--bg-soft); border: 1px dashed var(--border-lit);
}
.number-val { font-family: var(--mono); font-size: clamp(1.15rem, 5vw, 1.6rem); font-weight: 600;
              letter-spacing: .02em; user-select: all; }

.code-box {
  display: grid; gap: 6px; padding: 18px; border-radius: var(--radius);
  background: var(--accent-dim); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  text-align: center;
  animation: pop .35s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.code-val { font-family: var(--mono); font-size: clamp(1.7rem, 9vw, 2.6rem); font-weight: 700;
            letter-spacing: .16em; color: var(--accent); user-select: all; }

/* ------------------------------------------------------------------ flashes */
.flash {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: .9rem;
  border: 1px solid var(--border); background: var(--bg-card);
}
.flash-success { border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-dim); }
.flash-error   { border-color: color-mix(in srgb, var(--danger) 40%, transparent);
                 background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* ------------------------------------------------------------------- misc */
.empty { display: grid; gap: 8px; place-items: center; padding: 40px 20px; text-align: center; }
.empty svg { width: 42px; height: 42px; color: var(--text-mute); opacity: .6; }

.skel { background: linear-gradient(90deg, var(--bg-soft) 25%, var(--bg-hover) 50%, var(--bg-soft) 75%);
        background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

.divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Missing flag/icon: keep the layout box, drop the broken-image glyph. */
.img-missing { visibility: hidden; }

.toast {
  position: fixed; inset-inline: 16px; bottom: 84px; z-index: 90;
  margin-inline: auto; max-width: 380px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--border-lit);
  box-shadow: var(--shadow); font-size: .9rem; text-align: center;
  animation: rise .25s ease;
}
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

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