/* Mahara demo system. Rules: demos/DESIGN_RESEARCH.md. Logical properties only (RTL-first). */
@import url("fonts.css");

:root {
  --canvas: #f4f2ed;      /* warm ivory, not clinical blue-grey */
  --surface: #ffffff;
  --sunken: #ebe8e1;
  --ink: #16191d;
  --body: #3b4048;
  --muted: #646870;       /* 5.0:1 on canvas */
  --hair: #e2ded5;
  --hair-strong: #cdc8bd;
  --primary: #16191d;     /* actions are near-black; brand accent is rationed */
  --on-primary: #ffffff;
  --accent: #1d5c4d;      /* overwritten from BRAND.accent */
  --accent-soft: color-mix(in srgb, var(--accent) 10%, white);
  --accent-line: color-mix(in srgb, var(--accent) 35%, white);
  --success: #1e7a4c;
  --success-soft: #e3f1e8;
  --warn: #9a4f0a;
  --warn-soft: #f8ecdc;
  --danger: #b3261e;
  --danger-soft: #f9e3e1;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --pill: 999px;
  --font: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif;
  --tap: 44px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
:lang(en) { --font: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--canvas); color: var(--body); font-family: var(--font);
  font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
:lang(en) body, body:lang(en) { line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
.num, time, .price { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 16px; height: 16px; }
[dir="rtl"] svg.flip { transform: scaleX(-1); }   /* directional arrows only */
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- type ---------- */
.t-screen { font-size: 22px; line-height: 1.3; font-weight: 600; color: var(--ink); margin: 0; }
.t-title { font-size: 17px; line-height: 1.4; font-weight: 600; color: var(--ink); margin: 0; }
.t-label { font-size: 15px; font-weight: 500; color: var(--ink); }
.t-meta { font-size: 13px; line-height: 1.5; color: var(--muted); }
:lang(en) .t-screen { letter-spacing: -0.01em; }
.eyebrow { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 8px; }

/* ---------- app shell ---------- */
.app { position: relative; display: flex; flex-direction: column; height: 100dvh; max-width: 480px; margin-inline: auto; background: var(--canvas); overflow: hidden; }
.demobar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--ink); color: #d9d6cf; font-size: 13px; flex: none; }
.demobar .tag { color: #9c988f; }
.seg { display: inline-flex; background: rgba(255,255,255,.08); border-radius: var(--pill); padding: 3px; margin-inline-start: auto; }
.seg button { min-height: 32px; padding: 0 12px; border-radius: var(--pill); color: #bdb9b0; font-size: 13px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 60px; flex: none; }
.topbar .grow { flex: 1; min-width: 0; }
.iconbtn { width: var(--tap); height: var(--tap); display: grid; place-items: center; border-radius: var(--pill); color: var(--ink); flex: none; }
.iconbtn:active { background: var(--sunken); }
.langbtn { min-height: 44px; padding: 0 12px; border: 1px solid var(--hair-strong); border-radius: var(--pill); font-size: 13px; font-weight: 500; color: var(--ink); }
.screen { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 24px; scroll-padding-bottom: 96px; }
.screen.has-dock { padding-bottom: 112px; }

/* ---------- brand mark ---------- */
.mark { width: 40px; height: 40px; border-radius: var(--r-md); background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 18px; flex: none; overflow: hidden; }
.mark img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- tab bar ---------- */
.tabbar { flex: none; display: grid; grid-template-columns: repeat(var(--tabs, 3), 1fr); border-top: 1px solid var(--hair); background: color-mix(in srgb, var(--canvas) 92%, transparent); backdrop-filter: blur(12px); padding-bottom: env(safe-area-inset-bottom); }
.tab { min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 13px; font-weight: 500; color: var(--muted); }
.tab[aria-current="page"] { color: var(--accent); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-lg); }
.section { margin-top: 24px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.list { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-lg); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 64px; width: 100%; text-align: start; }
.row + .row { border-top: 1px solid var(--hair); }
button.row:active, a.row:active { background: var(--sunken); }
.row .grow { flex: 1; min-width: 0; }
.row .end { text-align: end; flex: none; }
.chev { color: var(--hair-strong); }
.avatar { width: 44px; height: 44px; border-radius: var(--pill); background: var(--sunken); color: var(--ink); display: grid; place-items: center; font-weight: 600; font-size: 15px; flex: none; }

/* ---------- buttons ---------- */
.btn { min-height: 52px; padding: 0 20px; border-radius: var(--r-md); font-weight: 600; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .12s var(--ease), background .12s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary[disabled] { background: var(--hair-strong); color: #fff; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--hair-strong); }
.btn-quiet { min-height: var(--tap); padding: 0 12px; color: var(--ink); font-weight: 500; font-size: 15px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }
a.btn { text-decoration: none; }
.btn .spin { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* bottom dock for the screen's one primary action */
.dock { position: absolute; inset-inline: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--canvas) 70%, transparent); }
.app.with-tabs .dock { bottom: 57px; }
.dock .summary { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }

/* ---------- chips / segmented ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip { min-height: 44px; padding: 0 14px; border-radius: var(--pill); border: 1px solid var(--hair-strong); background: var(--surface); font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }   /* option groups that must all be visible */
.tabs2 { display: grid; grid-template-columns: 1fr 1fr; background: var(--sunken); padding: 4px; border-radius: var(--r-md); }
.tabs2 button { min-height: 44px; border-radius: 9px; font-weight: 500; font-size: 14px; color: var(--muted); }
.tabs2 button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* ---------- status pills ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: var(--pill); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-ok { background: var(--success-soft); color: var(--success); }
.s-wait { background: var(--sunken); color: var(--body); }
.s-warn { background: var(--warn-soft); color: var(--warn); }
.s-bad { background: var(--danger-soft); color: var(--danger); }

/* ---------- forms ---------- */
.field { display: block; margin-top: 16px; }
.field > span { display: block; font-size: 14px; font-weight: 500; color: var(--ink); margin-bottom: 6px; }
.input { width: 100%; min-height: 52px; padding: 0 14px; border: 1px solid var(--hair-strong); border-radius: var(--r-md); background: var(--surface); font-size: 16px; color: var(--ink); }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(22,25,29,.08); }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { min-height: 88px; padding: 12px 14px; resize: none; line-height: 1.5; }
.phone-in { display: flex; direction: ltr; border: 1px solid var(--hair-strong); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.phone-in:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(22,25,29,.08); }
.phone-in.bad { border-color: var(--danger); }
.phone-in .cc { display: grid; place-items: center; padding: 0 12px; background: var(--sunken); color: var(--body); font-size: 15px; border-inline-end: 1px solid var(--hair); }
.phone-in input { flex: 1; border: 0; min-height: 50px; padding: 0 12px; font-size: 16px; letter-spacing: .02em; background: transparent; outline: none; }
.err { display: flex; gap: 6px; align-items: center; color: var(--danger); font-size: 13px; margin-top: 6px; }
.help { color: var(--muted); font-size: 13px; margin-top: 6px; }
.radio-row { display: flex; gap: 12px; align-items: center; padding: 14px 16px; min-height: 60px; width: 100%; text-align: start; }
.radio-row + .radio-row { border-top: 1px solid var(--hair); }
.radio-dot { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--hair-strong); flex: none; display: grid; place-items: center; }
.radio-row[aria-checked="true"] .radio-dot { border-color: var(--ink); }
.radio-row[aria-checked="true"] .radio-dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }

/* ---------- skeleton / empty / error ---------- */
.sk { background: linear-gradient(90deg, var(--sunken) 0%, #f3f1ec 50%, var(--sunken) 100%); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: var(--r-sm); }
@keyframes sk { to { background-position: -200% 0; } }
.state { text-align: center; padding: 32px 20px; }
.state .ico { width: 48px; height: 48px; border-radius: var(--pill); background: var(--sunken); color: var(--ink); display: grid; place-items: center; margin: 0 auto 12px; }
.state p { margin: 6px auto 16px; max-width: 30ch; color: var(--muted); font-size: 14px; }

/* ---------- sheet + toast ---------- */
.scrim { position: absolute; inset: 0; background: rgba(22,25,29,.4); z-index: 20; animation: fade .18s var(--ease); }
.sheet { position: absolute; inset-inline: 0; bottom: 0; z-index: 21; background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .22s var(--ease); }
.sheet .grab { width: 36px; height: 4px; border-radius: 4px; background: var(--hair-strong); margin: 4px auto 14px; }
.toast { position: absolute; inset-inline: 16px; bottom: 88px; z-index: 30; background: var(--ink); color: #fff; border-radius: var(--r-md); padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: center; animation: up .2s var(--ease); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(16px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- desktop presentation: phone frame + side panel ---------- */
.stage-info { display: none; }
@media (min-width: 900px) {
  body { display: grid; place-items: center; min-height: 100vh; background: #e9e6df; }
  .stage { display: grid; grid-template-columns: minmax(280px, 380px) auto; gap: 64px; align-items: center; padding: 16px 40px; }
  .stage-info { display: block; color: var(--body); }
  .stage-info h1 { font-size: 30px; line-height: 1.2; color: var(--ink); font-weight: 600; margin: 16px 0 12px; }
  :lang(en) .stage-info h1 { letter-spacing: -0.015em; }
  .stage-info p { margin: 0 0 20px; max-width: 34ch; }
  .stage-info .qr { background: #fff; border: 1px solid var(--hair); border-radius: var(--r-md); padding: 14px; display: inline-flex; gap: 14px; align-items: center; }
  .stage-info .qr canvas, .stage-info .qr img { width: 96px !important; height: 96px !important; }
  .stage-info .by { margin-top: 28px; font-size: 13px; color: var(--muted); }
  .device { width: 402px; height: 856px; border-radius: 62px; background: #1b1c1e; padding: 12px; position: relative;
    box-shadow: 0 0 0 1px #3a3b3e, 0 40px 80px -30px rgba(0,0,0,.45); }
  .device::after { content: ""; position: absolute; top: 24px; left: 50%; transform: translateX(-50%); width: 120px; height: 34px; border-radius: 20px; background: #000; z-index: 50; }
  .device .app { height: 100%; max-width: none; border-radius: 50px; }
  .device .sbar { display: flex; }
}
.sbar { display: none; justify-content: space-between; align-items: center; padding: 18px 32px 6px; height: 52px; font-size: 15px; font-weight: 600; color: var(--ink); background: var(--canvas); flex: none; direction: ltr; }
.sbar svg { height: 12px; fill: var(--ink); }

/* ---------- shared components (both demos) ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.two .btn { text-decoration: none; min-height: 48px; font-size: 15px; }

/* date strip: week starts today, Friday shows closed */
.days { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding: 2px 16px 4px; scroll-snap-type: x proximity; }
.days::-webkit-scrollbar { display: none; }
.day { flex: none; width: 62px; min-height: 80px; border-radius: var(--r-md); border: 1px solid var(--hair); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; scroll-snap-align: center; }
.day .dname { font-size: 13px; color: var(--muted); font-weight: 500; }
.day .dnum { font-size: 20px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.day .dmon { font-size: 12.5px; color: var(--muted); }
.day[data-off] { background: transparent; border-style: dashed; }
.day[data-off] .dnum { color: var(--muted); }
.day[aria-selected="true"] { background: var(--ink); border-color: var(--ink); }
.day[aria-selected="true"] span, .day[aria-selected="true"][data-off] .dnum { color: #fff; }

.banner { display: flex; gap: 12px; align-items: center; margin-top: 12px; padding: 12px 14px; border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger); }
.banner .t-label { color: var(--danger); }
.banner .btn-quiet { white-space: nowrap; color: var(--danger); text-decoration: underline; text-underline-offset: 3px; }

.done-mark { width: 52px; height: 52px; border-radius: var(--pill); background: var(--success-soft); color: var(--success); display: grid; place-items: center; margin: 8px 0 14px; }
.done-mark svg { width: 26px; height: 26px; stroke-width: 2.25; }
#focus-me:focus { outline: none; }
.ticket { padding: 18px 16px 6px; }
.ticket-when { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px dashed var(--hair-strong); }
.ticket-when .big { font-size: 32px; font-weight: 600; color: var(--ink); line-height: 1.1; }
.kv { margin: 0; }
.kv > div { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding: 10px 0; }
.kv > div + div { border-top: 1px solid var(--hair); }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; color: var(--ink); font-size: 14.5px; }
.switch { width: 44px; height: 26px; border-radius: var(--pill); background: var(--hair-strong); position: relative; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: inset-inline-start .15s var(--ease); }
[aria-checked="true"] > .switch { background: var(--ink); }
[aria-checked="true"] > .switch::after { inset-inline-start: 21px; }
a.row { color: inherit; text-decoration: none; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 18px; background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-lg); }
.stats > div { padding: 14px 16px; display: flex; flex-direction: column; }
.stats > div + div { border-inline-start: 1px solid var(--hair); }
.big2 { font-size: 26px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.sample { margin-top: 6px; }

.fresh-tag { color: color-mix(in srgb, var(--accent) 78%, black); font-weight: 500; display: flex; gap: 4px; align-items: center; }
.fresh { background: var(--accent-soft); }
.danger { color: var(--danger) !important; }
.danger-btn { background: var(--danger); }
