/* Yalla Darija — one stylesheet, no build step, no framework.

   The visual language is zellige: the geometric tilework you see on every riad wall in
   Fès. It shows up as the hero backdrop, as section rules, and in the eight-point star
   that marks headings. The palette is taken from the tiles themselves — the deep green
   of glazed zellige, saffron, and the terracotta of a Marrakech wall. */

/* ---------------------------------------------------------------- tokens -- */

:root {
  /* Zellige green, the anchor of the whole palette. */
  --accent: #0b6b57;
  --accent-deep: #084b3e;
  --accent-bright: #129578;
  --accent-soft: #e3f1ec;
  --accent-ink: #ffffff;

  /* Saffron and terracotta, used sparingly so they stay accents. */
  --saffron: #d4952a;
  --terracotta: #c0563a;

  --bg: #fbf8f2;
  --bg-tint: #f4eee2;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e8dfcd;
  --border-strong: #d8cbb2;

  --text: #16130f;
  --text-soft: #4a423a;
  --muted: #7a6f61;

  --radius: 16px;
  --radius-lg: 24px;
  --measure: 34rem;

  --shadow-sm: 0 1px 2px rgba(22, 19, 15, .05), 0 2px 8px rgba(22, 19, 15, .04);
  --shadow-md: 0 2px 4px rgba(22, 19, 15, .05), 0 12px 28px rgba(22, 19, 15, .08);
  --shadow-lg: 0 4px 10px rgba(22, 19, 15, .06), 0 24px 56px rgba(22, 19, 15, .12);

  --font-display: "Fraunces", ui-serif, Georgia, serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-arabic: "Amiri", "Noto Naskh Arabic", "Geeza Pro", serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #3fc6a5;
    --accent-deep: #9fe6d3;
    --accent-bright: #5fdcbb;
    --accent-soft: #10312a;
    --accent-ink: #04231c;

    --saffron: #e8b45c;
    --terracotta: #e08468;

    --bg: #100e0c;
    --bg-tint: #171412;
    --surface: #1a1715;
    --surface-raised: #211d1a;
    --border: #2e2823;
    --border-strong: #423a32;

    --text: #f6f1e8;
    --text-soft: #d3c9bb;
    --muted: #9d9184;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, .4), 0 12px 28px rgba(0, 0, 0, .45);
    --shadow-lg: 0 4px 10px rgba(0, 0, 0, .45), 0 24px 56px rgba(0, 0, 0, .55);
  }
}

:root[data-theme="dark"] {
  --accent: #3fc6a5; --accent-deep: #9fe6d3; --accent-bright: #5fdcbb;
  --accent-soft: #10312a; --accent-ink: #04231c;
  --saffron: #e8b45c; --terracotta: #e08468;
  --bg: #100e0c; --bg-tint: #171412; --surface: #1a1715; --surface-raised: #211d1a;
  --border: #2e2823; --border-strong: #423a32;
  --text: #f6f1e8; --text-soft: #d3c9bb; --muted: #9d9184;
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------ typography -- */

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "SOFT" 20, "WONK" 1;
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-wrap: balance;
  color: var(--text);
}

h1 { font-size: clamp(2rem, 1.35rem + 2.9vw, 3.35rem); margin: 0 0 16px; }
h2 { font-size: clamp(1.4rem, 1.15rem + 1.2vw, 1.95rem); margin: 56px 0 18px; }
h3 { font-size: 1.15rem; margin: 30px 0 10px; }

p { max-width: var(--measure); color: var(--text-soft); }
.lede { font-size: clamp(1.05rem, 1rem + .35vw, 1.2rem); color: var(--text-soft); }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-bright); }

:focus-visible {
  outline: 2.5px solid var(--accent-bright);
  outline-offset: 3px;
  border-radius: 6px;
}

main { padding: 0 20px 80px; }
.wrap { max-width: var(--measure); margin-inline: auto; }
.wrap--wide { max-width: 1080px; margin-inline: auto; }

/* An eight-point zellige star before section headings. */
.wrap--wide > h2::before,
.wrap > h2::before {
  content: "";
  display: inline-block;
  width: .62em;
  height: .62em;
  margin-right: .5em;
  vertical-align: baseline;
  background: var(--accent);
  opacity: .85;
  clip-path: polygon(50% 0, 62% 25%, 88% 13%, 79% 40%, 100% 50%, 79% 60%, 88% 87%,
                     62% 75%, 50% 100%, 38% 75%, 12% 87%, 21% 60%, 0 50%, 21% 40%,
                     12% 13%, 38% 25%);
}

/* ---------------------------------------------------------------- header -- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: center;
  justify-content: space-between;
  padding: 13px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.wordmark img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: contain;
}

.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }

.site-nav a {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: .93rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.site-nav a:hover { color: var(--text); background: var(--bg-tint); }

.lang-switch {
  margin-left: 6px;
  font-weight: 700 !important;
  font-size: .78rem !important;
  letter-spacing: .06em;
  color: var(--accent) !important;
  border: 1px solid var(--border-strong);
}
.lang-switch:hover { background: var(--accent-soft) !important; }

/* ----------------------------------------------------------------- hero -- */

.hero {
  position: relative;
  isolation: isolate;
  max-width: 820px;
  margin-inline: auto;
  padding: clamp(48px, 7vw, 92px) 0 20px;
  text-align: center;
}

/* The zellige tile, faded almost out — texture rather than decoration. */
.hero::before {
  content: "";
  position: absolute;
  inset: -40px -50vw 0;
  z-index: -1;
  background-image: url("pattern.svg");
  background-size: 150px;
  background-position: center top;
  opacity: .055;
  mask-image: radial-gradient(ellipse 70% 80% at 50% 25%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse 70% 80% at 50% 25%, #000 0%, transparent 72%);
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero::before { opacity: .09; filter: invert(1); }
}

.hero h1 { margin-bottom: 18px; }
.hero .lede { margin-inline: auto; max-width: 33rem; }

.hero-art {
  display: block;
  width: min(220px, 46vw);
  height: auto;
  margin: 0 auto 6px;
  filter: drop-shadow(0 18px 34px rgba(11, 107, 87, .18));
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 20px;
}

/* --------------------------------------------------------------- buttons -- */

.store-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-top: 28px;
}

/* The supplied badge artwork is white on transparency, so it needs a dark plate to be
   visible on the cream background. Near-black rather than pure black, which sits better
   against a warm page and matches how both stores present their own badges. */
.store-badge {
  display: inline-flex;
  background: #0d0d0f;
  border-radius: 11px;
  overflow: hidden;
  line-height: 0;
  box-shadow: var(--shadow-md);
  transition: transform .16s ease, box-shadow .16s ease;
}
.store-badge:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.store-badge img {
  display: block;
  height: 50px;
  width: auto;
}

@media (max-width: 400px) {
  .store-badge img { height: 44px; }
}

/* ----------------------------------------------------------------- cards -- */

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  margin: 26px 0;
  padding: 0;
  list-style: none;
}

.card {
  position: relative;
  display: block;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.card::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  inset-block: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  opacity: 0;
  transition: opacity .16s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  color: inherit;
}
.card:hover::after { opacity: 1; }

.card strong {
  display: block;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
}
.card span {
  display: block;
  color: var(--muted);
  font-size: .89rem;
}

/* --------------------------------------------------------------- entries -- */

.entry {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 12px 0;
  box-shadow: var(--shadow-sm);
}

.entry .english {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.darija {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.35;
  margin: 2px 0;
}
.darija a { text-decoration: none; color: inherit; }
.darija a:hover { text-decoration: underline; }

.arabic {
  font-family: var(--font-arabic);
  font-size: 1.75rem;
  line-height: 2;
  direction: rtl;
  text-align: right;
  color: var(--text);
  margin: 2px 0;
}

.plain {
  font-size: .89rem;
  color: var(--muted);
}

.pill {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg-tint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  margin-right: 6px;
}

/* --------------------------------- the headline answer on a phrase page -- */

.answer {
  position: relative;
  overflow: hidden;
  background: linear-gradient(150deg,
              color-mix(in srgb, var(--accent-soft) 85%, var(--surface)),
              var(--surface) 72%);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: var(--radius-lg);
  padding: 30px 32px;
  margin: 26px auto 22px;
  max-width: var(--measure);
  box-shadow: var(--shadow-md);
}

/* A quarter tile in the corner, so the block reads as designed rather than boxed. */
.answer::after {
  content: "";
  position: absolute;
  right: -46px;
  bottom: -46px;
  width: 168px;
  height: 168px;
  background-image: url("pattern.svg");
  background-size: 96px;
  opacity: .07;
  pointer-events: none;
}

.answer .darija { font-size: clamp(1.7rem, 1.35rem + 1.5vw, 2.3rem); margin: 0 0 2px; }
.answer .darija + .plain { margin-bottom: 12px; }
.answer .arabic { font-size: clamp(2rem, 1.6rem + 1.8vw, 2.6rem); }

.meaning { max-width: var(--measure); margin-inline: auto; }

/* ----------------------------------------------------------------- audio -- */

.audio-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

/* The native player is replaced by this button when the enhancement script runs; it
   stays in the DOM and simply reappears if the script never loads. */
.audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 18px 9px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.audio-btn:hover { background: var(--accent-soft); transform: translateY(-1px); }
.audio-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}

.audio-btn .glyph {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent currentColor;
}
.audio-btn[aria-pressed="true"] .glyph {
  width: 10px;
  height: 12px;
  border: none;
  background:
    linear-gradient(currentColor, currentColor) left / 3.5px 100% no-repeat,
    linear-gradient(currentColor, currentColor) right / 3.5px 100% no-repeat;
}

.audio { width: 100%; max-width: 320px; height: 36px; margin-top: 10px; }
.audio-row .audio { margin-top: 0; }

/* ------------------------------------------------------------ dictionary -- */

.letter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 24px 0 32px;
  padding: 0;
  list-style: none;
}
.letter-nav a {
  display: grid;
  place-items: center;
  min-width: 46px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: var(--font-display);
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform .14s ease, border-color .14s ease, color .14s ease;
}
.letter-nav a:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: var(--accent);
}

.word-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.word-table th, .word-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.word-table tr:last-child td { border-bottom: none; }
.word-table tbody tr:nth-child(odd) { background: color-mix(in srgb, var(--bg-tint) 45%, transparent); }
.word-table th {
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  background: var(--bg-tint);
}
.word-table td.darija-cell { color: var(--accent); font-weight: 600; }
.word-table td .plain { display: block; font-weight: 400; }

/* ------------------------------------------------------------------- cta -- */

.cta {
  position: relative;
  overflow: hidden;
  background: linear-gradient(140deg, var(--accent-deep), var(--accent));
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  margin: 56px auto;
  max-width: 720px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.cta::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("pattern.svg");
  background-size: 128px;
  opacity: .08;
  filter: invert(1);
  pointer-events: none;
}
.cta > * { position: relative; }
.cta h2 { margin: 0 0 10px; color: #fff; }
.cta h2::before { display: none; }
.cta p { margin-inline: auto; color: rgba(255, 255, 255, .84); }
.cta .store-badge {
  box-shadow: 0 2px 10px rgba(0, 0, 0, .28);
}

/* In dark mode the accent tokens invert to pale mint, which turned this panel into a
   glaring light block on a near-black page. Dark mode gets its own deep green instead,
   keeping the panel a quiet emphasis rather than a flare. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cta {
    background: linear-gradient(140deg, #0c3a30, #11594a);
    border: 1px solid #1c6d5b;
  }
  :root:not([data-theme="light"]) .cta h2 { color: #eafaf5; }
  :root:not([data-theme="light"]) .cta p { color: rgba(234, 250, 245, .78); }
  :root:not([data-theme="light"]) .cta::before { filter: invert(1); opacity: .06; }
}

:root[data-theme="dark"] .cta {
  background: linear-gradient(140deg, #0c3a30, #11594a);
  border: 1px solid #1c6d5b;
}
:root[data-theme="dark"] .cta h2 { color: #eafaf5; }
:root[data-theme="dark"] .cta p { color: rgba(234, 250, 245, .78); }

/* ------------------------------------------------------------ breadcrumbs -- */

.breadcrumbs {
  max-width: 1080px;
  margin: 24px auto 8px;
  font-size: .84rem;
  color: var(--muted);
}
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }

/* ------------------------------------------------------------------- faq -- */

details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 10px 0;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease;
}
details[open] { border-color: var(--border-strong); }
summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  font-size: 1.25rem;
  color: var(--accent);
  line-height: 1;
  transition: transform .18s ease;
}
details[open] summary::after { transform: rotate(45deg); }
details p { margin: 12px 0 0; max-width: none; }

/* ---------------------------------------------------------------- footer -- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-tint);
  padding: 48px 20px 60px;
  text-align: center;
  color: var(--muted);
}
.site-footer strong { color: var(--text); font-family: var(--font-display); }
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  justify-content: center;
  margin-top: 22px;
  font-size: .92rem;
}
.footer-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 5px 11px;
  border-radius: 999px;
}
.footer-nav a:hover { color: var(--accent); background: var(--surface); }

/* --------------------------------------------------------------- phones -- */

@media (max-width: 640px) {
  body { font-size: 16px; }
  main { padding-inline: 16px; }
  .site-header { padding: 11px 16px; }
  .site-nav a { padding: 6px 9px; font-size: .88rem; }
  .answer { padding: 24px 20px; border-radius: var(--radius); }
  .cta { padding: 32px 22px; margin: 44px auto; border-radius: var(--radius); }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px 15px; }
  .card strong { font-size: .95rem; }
}

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


/* ----------------------------------------------------------------- legal -- */

/* Wider than an article and plainer than the rest of the site: these are documents
   people scan for one clause, and app-store reviewers open them cold. */
.legal { max-width: 760px; }
.legal h1 { margin-bottom: 10px; }
.legal .lede { max-width: none; }

.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  max-width: none;
  margin: 18px 0 30px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  color: var(--muted);
}

.legal-toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 36px;
  box-shadow: var(--shadow-sm);
}
.legal-toc .nav-title {
  margin: 0 0 10px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.legal-toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 2;
  column-gap: 28px;
}
.legal-toc li { margin-bottom: 6px; break-inside: avoid; }
.legal-toc a { font-size: .93rem; text-decoration: none; }
.legal-toc a:hover { text-decoration: underline; }

.legal-section { margin-bottom: 34px; scroll-margin-top: 80px; }
.legal-section h2 { margin-top: 0; font-size: 1.32rem; }
.legal-section h3 {
  margin: 22px 0 8px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.legal-section p, .legal-section li { max-width: none; color: var(--text-soft); }
.legal-section ul { padding-left: 1.15rem; }
.legal-section li { margin-bottom: 7px; }
.legal-section .note {
  background: var(--bg-tint);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 12px 16px;
  font-size: .94rem;
}

.legal-cross {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 44px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  justify-content: center;
  margin-top: 12px;
  font-size: .86rem;
}
.footer-legal a { color: var(--muted); text-decoration: none; padding: 4px 9px; }
.footer-legal a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 560px) {
  .legal-toc ul { columns: 1; }
}


/* The boundary where the free preview stops.

   Deliberately not the usual green panel: this one sits at the end of a truncated list
   and needs to read as "the list continues", not as an advert that happens to be there.
   The fade above it does most of that work. */
.cta--preview {
  position: relative;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
}
.cta--preview::before {
  background-image: url("pattern.svg");
  background-size: 128px;
  opacity: .05;
  filter: none;
}
.cta--preview::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -74px;
  height: 74px;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}
.cta--preview h2 { color: var(--text); }
.cta--preview h2::before { display: none; }
.cta--preview p { color: var(--muted); }


/* ---------------------------------------------------------------- search -- */

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

.search {
  display: flex;
  gap: 8px;
  max-width: 520px;
  margin: 26px auto 0;
}

.search input {
  flex: 1;
  min-width: 0;
  padding: 14px 18px;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search input::placeholder { color: var(--muted); }
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-md), 0 0 0 4px var(--accent-soft);
}
/* The browser's own clear button is a different grey on every platform. */
.search input::-webkit-search-cancel-button { filter: grayscale(1) opacity(.5); }

.search button {
  padding: 14px 24px;
  font: inherit;
  font-weight: 600;
  color: var(--accent-ink);
  background: linear-gradient(145deg, var(--accent-bright), var(--accent));
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.search button:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.search-results {
  max-width: 520px;
  margin: 12px auto 0;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.search-results[hidden] { display: none; }

.search-hit {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.search-hit:last-of-type { border-bottom: none; }
a.search-hit:hover { background: var(--accent-soft); color: inherit; }
.search-hit--plain { cursor: default; }

.search-en { font-weight: 500; }
.search-da {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--accent);
  text-align: right;
}

.search-empty, .search-more {
  margin: 0;
  padding: 14px 18px;
  font-size: .9rem;
  color: var(--muted);
  max-width: none;
}
.search-more {
  border-top: 1px solid var(--border);
  background: var(--bg-tint);
  text-align: center;
}

@media (max-width: 480px) {
  .search { flex-direction: column; border-radius: var(--radius); }
  .search button { width: 100%; }
}


/* ------------------------------------------------------------ translator -- */

.translator {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin: 26px 0 8px;
  box-shadow: var(--shadow-md);
}

.translator-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.translator-bar select {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-tint);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.translator-target {
  flex: 1;
  padding: 10px 14px;
  font-weight: 600;
  text-align: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  border-radius: 999px;
}

.translator-swap {
  flex: none;
  width: 42px; height: 42px;
  font-size: 1.15rem;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  transition: transform .18s ease, background .15s ease;
}
.translator-swap:hover { background: var(--accent-soft); transform: rotate(180deg); }

/* Swapped direction: the dialect becomes the input side. */
.translator[data-direction="from"] .translator-bar { flex-direction: row-reverse; }

.translator textarea {
  width: 100%;
  padding: 15px 18px;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
}
.translator textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.translator textarea:disabled { opacity: .55; cursor: not-allowed; }

.translator-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.translator-actions button {
  padding: 13px 30px;
  font: inherit;
  font-weight: 600;
  color: var(--accent-ink);
  background: linear-gradient(145deg, var(--accent-bright), var(--accent));
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.translator-actions button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.translator-actions button:disabled { opacity: .5; cursor: not-allowed; }

.translator-counter { font-size: .88rem; color: var(--muted); }

.translator-output {
  margin-top: 18px;
  padding: 20px 22px;
  background: linear-gradient(150deg,
              color-mix(in srgb, var(--accent-soft) 80%, var(--surface)), var(--surface) 70%);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  border-radius: var(--radius);
}
.translator-output[hidden] { display: none; }
.translator-output .arabic { font-size: 1.85rem; margin-bottom: 4px; }
.translator-output .darija { font-size: 1.35rem; }

.translator-error { margin: 0; color: var(--terracotta); }

.translator-notice {
  padding: 12px 16px;
  background: var(--bg-tint);
  border-left: 3px solid var(--saffron);
  border-radius: 0 10px 10px 0;
  font-size: .94rem;
  max-width: none;
}

.translator-paywall {
  margin-top: 18px;
  padding: 26px 24px;
  text-align: center;
  background: var(--bg-tint);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.translator-paywall[hidden] { display: none; }
.translator-paywall h2 { margin: 0 0 8px; font-size: 1.25rem; }
.translator-paywall h2::before { display: none; }
.translator-paywall p { margin: 0 auto; color: var(--muted); }

@media (max-width: 560px) {
  .translator { padding: 16px; }
  .translator-bar { flex-wrap: wrap; }
  .translator-bar select, .translator-target { flex-basis: 100%; text-align: center; }
  .translator-swap { margin: 0 auto; }
  .translator-actions { flex-direction: column; align-items: stretch; text-align: center; }
}


/* --------------------------------------------------------------- sketches -- */

/* Loose line drawings that sit beside a section, in the spirit of a notebook margin.
   The ink is currentColor and the blob is the accent at low opacity, so they follow the
   theme into dark mode without a second asset. */
.sketch {
  width: 100%;
  max-width: 220px;
  height: auto;
  color: var(--text);
  flex: none;
}

.sketch-blob {
  color: var(--accent);
  opacity: .14;
}

.sketch-word {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  fill: currentColor;
  stroke: none;
}
.sketch-word--accent { fill: var(--accent); }

.sketch-arabic {
  font-family: var(--font-arabic);
  font-size: 22px;
  fill: currentColor;
  stroke: none;
}
.sketch-accent { color: var(--accent); }
.sketch-saffron { color: var(--saffron); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sketch-blob { opacity: .2; }
}

/* A section that pairs copy with a sketch. */
.with-sketch {
  display: flex;
  align-items: center;
  gap: clamp(20px, 4vw, 48px);
}
.with-sketch > div { flex: 1; min-width: 0; }
.with-sketch h2 { margin-top: 0; }

@media (max-width: 620px) {
  .with-sketch { flex-direction: column-reverse; align-items: flex-start; gap: 14px; }
  .sketch { max-width: 180px; align-self: center; }
}


/* Homepage illustrations are intentionally drawn in the same single-ink language:
   they feel like notes from a Cairo phrasebook, not stock app mascots. */
.hero-cairo {
  display: block;
  width: min(310px, 72vw);
  height: auto;
  margin: 0 auto 12px;
  color: var(--text);
  filter: drop-shadow(0 16px 24px rgba(11, 107, 87, .12));
}
.hero-cairo-wash { fill: var(--accent-soft); stroke: none; }
.hero-cairo-accent { color: var(--accent); }
.hero-cairo-saffron { color: var(--saffron); }
.hero-cairo-label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  fill: currentColor;
  stroke: none;
}
.hero-cairo-arabic {
  font-family: var(--font-arabic);
  font-size: 22px;
  fill: currentColor;
  stroke: none;
}
