/* Qazzly shared sheet for every page except the qazzly.com home (which uses assets/system.css + home.css).
   Copied into qazzly.ma and qazzly.app by their builders, together with /assets/fonts and /assets/glyphs.
   Same tokens as the home: navy #14213D, cream #F4EDE0, coral #FF6B5B, Schibsted Grotesk, pill buttons
   (coral with navy text, 5.7:1), hairlines at 11% navy, navy focus rings on cream. CSP-safe: no data: URLs. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/assets/fonts/SchibstedGrotesk-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --navy: #14213D; --cream: #F4EDE0; --coral: #FF6B5B;
  --ink: #14213D; --muted: #596274; --bg: #F4EDE0; --surface: #E7E2D7; --card: #FBF7F0; --field: #FFFDF9;
  --accent: #FF6B5B; --accent-ink: #14213D;
  --line: color-mix(in oklab, #14213D 11%, transparent);
  --line-strong: color-mix(in oklab, #14213D 20%, transparent);
  --field-line: #8A7F6C;                 /* 3.4:1 on cream: a visible input edge */
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --t-small: 14px; --t-body: 16px; --t-lead: 18px; --t-card: 18px;
  --t-h1: clamp(34px, 2.2vw + 24px, 56px);
  --t-h2: clamp(26px, 1vw + 21px, 36px);
  --t-h3: 20px;
  --t-stat: clamp(26px, .6vw + 22px, 32px);
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 20px;
  --gut: 24px; --container: 1280px; --nav: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1); --dur: 180ms;
}
@media (min-width: 640px) { :root { --gut: 48px; --nav: 72px; } }
@media (min-width: 1280px) { :root { --gut: 80px; --t-lead: 20px; --t-card: 20px; --t-h3: 22px; } }

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font: 400 var(--t-body)/1.55 var(--font); color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: clip;
}
body > main { flex: 1 0 auto; }
img { max-width: 100%; height: auto; display: block; }
[hidden] { display: none !important; }
a { color: var(--navy); text-decoration: underline; text-decoration-color: var(--coral); text-decoration-thickness: 2px; text-underline-offset: 4px; transition: text-decoration-color var(--dur) var(--ease); }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3 { font-family: var(--font); font-weight: 400; letter-spacing: -0.03em; text-wrap: balance; overflow-wrap: break-word; color: var(--ink); }
h1 { font-size: var(--t-h1); line-height: 1.06; margin: 0 0 var(--s-5); max-width: 22ch; }
h2 { font-size: var(--t-h2); line-height: 1.12; margin: var(--s-8) 0 var(--s-5); }
h3 { font-size: var(--t-h3); line-height: 1.25; letter-spacing: -0.015em; font-weight: 500; margin: var(--s-6) 0 var(--s-3); }
p { margin: 0 0 var(--s-4); text-wrap: pretty; }
ul, ol { margin: 0 0 var(--s-4); }
strong { font-weight: 600; }
::selection { background: color-mix(in oklab, var(--coral) 30%, transparent); }

.wrap { width: min(100% - 2 * var(--gut), var(--container)); margin-inline: auto; }
.narrow { max-width: 760px; }
/* a narrow page keeps the header's left line (as the home does) and a 760px reading column */
.wrap.narrow { max-width: none; }
.wrap.narrow > * { max-width: 760px; }

/* ---------------------------------------------------------------- header (the home's nav: cream, one hairline,
   the stack mark in coral beside the name, plain 15px words with an underline that grows on hover) */
.top { position: sticky; top: 0; z-index: 50; background: var(--bg); border-bottom: 1px solid var(--line); }
.bar { min-height: var(--nav); display: flex; align-items: center; gap: var(--s-3) var(--s-7); flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; gap: var(--s-2); flex: none; color: var(--ink); text-decoration: none;
        font: 500 22px/1 var(--font); letter-spacing: -0.02em; }
.mark { display: inline-block; flex: none; width: 22px; height: 22px; background: var(--coral);
        -webkit-mask: url("/assets/glyphs/stack.svg") center / contain no-repeat; mask: url("/assets/glyphs/stack.svg") center / contain no-repeat; }
/* the Qazzly logo (build/brand/v2: English face; .ma uses the Moroccan face): an <img>, so it needs no font and no CSP change.
   Height set here; width follows the artwork: 652:256 English, 738:256 Moroccan (the width/height attributes stop layout shift). */
.logo-img { display: block; flex: none; height: 40px; width: auto; }
.logo-sub { font: 500 20px/1 var(--font); letter-spacing: -0.02em; color: var(--muted); padding-top: 2px; }
.foot .logo-img { height: 34px; }
.foot .logo-sub { font-size: 17px; }
.top nav { display: flex; align-items: center; gap: var(--s-1); flex-wrap: wrap; min-width: 0; }
.top nav a {
  position: relative; display: inline-flex; align-items: center; height: 36px; padding: 0 var(--s-3); border-radius: var(--r-sm);
  font-size: 15px; font-weight: 500; color: var(--ink); text-decoration: none; white-space: nowrap;
}
.top nav a::before { content: ""; position: absolute; left: var(--s-3); right: var(--s-3); bottom: 0; height: 2px; border-radius: 2px;
  background: var(--coral); transform: scaleX(0); transform-origin: right; transition: transform var(--dur) var(--ease); }
.top nav a:hover::before, .top nav a:focus-visible::before { transform: scaleX(1); transform-origin: left; }
.top nav a[aria-current="page"]::before { transform: scaleX(1); background: var(--ink); }
@media (max-width: 639px) {
  /* a phone: no sticky bar (it would hide too much of a calculator); the words go on a row of their own
     under the logo, scrolling sideways inside the bar if they do not fit */
  .top { position: static; }
  .bar { padding-block: var(--s-3) 0; row-gap: var(--s-1); }
  .logo { font-size: 20px; min-height: 36px; }
  .top nav { flex-wrap: nowrap; overflow-x: auto; width: calc(100% + 2 * var(--gut)); margin-inline: calc(-1 * var(--gut)); padding: 0 var(--gut) var(--s-2);
             scrollbar-width: none; }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a { padding: 0 var(--s-2); font-size: 15px; }
  .top nav a:first-child { margin-left: calc(-1 * var(--s-2)); }
  .top nav a::before { left: var(--s-2); right: var(--s-2); }
}

/* ---------------------------------------------------------------- footer (the home's legal row: hairline above,
   the mark + name, then the small print; sites/legal.py adds its links as the last item of .wrap) */
.foot { margin-top: var(--s-9); border-top: 1px solid var(--line); color: var(--muted); font-size: var(--t-small); }
.foot .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-6); padding-block: var(--s-6) var(--s-7); }
.foot .logo { font-size: 20px; }
.foot .logo .mark { width: 18px; height: 18px; }
.foot p { margin: 0; }
.foot a { color: var(--ink); }
.foot .wrap > .logo, .foot .wrap > p { flex: none; }
.legal-links { display: inline-flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin-left: auto; }
.legal-links a { margin: 0; }
@media (max-width: 639px) { .foot .wrap { flex-direction: column; align-items: flex-start; } .legal-links { margin-left: 0; } }

/* ---------------------------------------------------------------- page head */
.hero { padding: var(--s-9) 0 var(--s-7); }
.hero h1 { max-width: 18ch; }
.hero p { font-size: var(--t-lead); line-height: 1.5; color: var(--muted); max-width: 46ch; margin-bottom: var(--s-6); }
.hero.small { padding: var(--s-8) 0 var(--s-5); }
.hero.small h1 { max-width: 24ch; }
.hero.small p { max-width: 58ch; }
@media (max-width: 639px) { .hero { padding: var(--s-7) 0 var(--s-6); } .hero.small { padding: var(--s-6) 0 var(--s-4); } }

/* ---------------------------------------------------------------- buttons: coral pills, navy words, a chevron */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: 10px var(--s-5); border: 1px solid transparent; border-radius: 999px;
  background: var(--coral); color: var(--navy); font: 500 var(--t-body)/1.2 var(--font); text-align: center;
  text-decoration: none; cursor: pointer; transition: background-color var(--dur) var(--ease);
}
.btn::after { content: ""; flex: none; width: 12px; height: 12px; margin-right: -2px; background: currentColor;
  -webkit-mask: url("/assets/glyphs/chevron.svg") center / contain no-repeat; mask: url("/assets/glyphs/chevron.svg") center / contain no-repeat;
  transition: transform var(--dur) var(--ease); }
.btn:hover { background: color-mix(in oklab, var(--coral) 86%, var(--navy)); }
.btn:hover::after { transform: translateX(3px); }
.btn:active { transform: translateY(1px) scale(.985); }
button.btn { -webkit-appearance: none; appearance: none; }

/* ---------------------------------------------------------------- cards and grids */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: var(--s-5); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; }
.card > img { background: var(--surface); border-bottom: 1px solid var(--line); }
.card .body { padding: var(--s-5); display: flex; flex-direction: column; flex: 1; }
.card h3 { margin: 0 0 var(--s-2); font-size: var(--t-card); line-height: 1.3; }
.card p { margin: 0 0 var(--s-3); color: var(--muted); }
.card .btn { margin-top: auto; align-self: flex-start; }
.card .note { margin-top: var(--s-4); }

.cta { margin-top: var(--s-8); padding: var(--s-6); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); }
.cta h2 { margin-top: 0; }
.cta + p, .cta + .fine { margin-top: var(--s-5); }
.cta > .btn, .cta p > .btn { margin-top: var(--s-2); }
@media (max-width: 639px) { .cta { padding: var(--s-5); } }

.fine { font-size: var(--t-small) !important; color: var(--muted); }
.note { color: var(--muted); margin-top: var(--s-5); }
.fine-list { color: var(--muted); font-size: 15px; padding-left: 20px; }
.fine-list li { margin-bottom: var(--s-2); }

/* ---------------------------------------------------------------- forms (calculators, the Darija search) */
.search, .calc label { display: block; font-weight: 500; margin: var(--s-4) 0 var(--s-2); }
.calc { display: grid; grid-template-columns: 1fr; max-width: 560px; }
.calc label { margin: var(--s-4) 0 var(--s-2); }
.calc > label:first-child { margin-top: 0; }
.calc > div > label { margin-top: var(--s-4); }
input, select, textarea { font: inherit; color: var(--ink); }
#q, .calc input, .calc select {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--field-line); border-radius: var(--r-md);
  background: var(--field); color: var(--ink); font: inherit;
}
#q { max-width: 560px; }
.tip { color: var(--muted); margin: calc(-1 * var(--s-2)) 0 var(--s-3); font-size: 15px; }
.found { margin-top: var(--s-4); padding: var(--s-4) var(--s-5); border: 1px solid var(--line); border-left: 4px solid var(--coral); border-radius: var(--r-md); background: var(--card); max-width: 560px; }
.found p { margin: 0 0 var(--s-2); font-weight: 500; }
.found ul { margin: 0; padding-left: 20px; color: var(--muted); }

.results { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: var(--s-3); margin: var(--s-6) 0 var(--s-2); }
.results div { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4) var(--s-5); }
.results span { display: block; color: var(--muted); font-size: var(--t-small); margin-bottom: var(--s-1); }
.results strong { display: block; font-size: var(--t-stat); font-weight: 400; line-height: 1.15; letter-spacing: -0.02em; }

/* ---------------------------------------------------------------- tables (the Darija phrase lists) */
.tw { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; font-weight: 500; letter-spacing: .01em; color: var(--muted); background: color-mix(in oklab, var(--surface) 55%, var(--card)); }
tr:last-child td { border-bottom: 0; }
td.lat { font-weight: 500; color: var(--navy); }
td.ar { font-size: 19px; text-align: right; white-space: nowrap; }
td.say { color: var(--muted); font-size: 14px; }
@media (max-width: 639px) { th, td { padding: 8px 10px; } .results div { padding: var(--s-3) var(--s-4); } .results strong { font-size: 24px; } }

/* ---------------------------------------------------------------- legal pages */
.legal { padding-top: var(--s-8); padding-bottom: var(--s-6); }
.legal h1 { font-size: clamp(32px, 1.6vw + 24px, 48px); }
.legal h2 { font-size: clamp(22px, .6vw + 19px, 28px); margin: var(--s-7) 0 var(--s-3); }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: var(--s-2); }

/* ---------------------------------------------------------------- focus: navy on cream (coral on cream is only 2.4:1) */
:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; border-radius: 2px; }
.btn:focus-visible { border-radius: 999px; }
#q:focus-visible, .calc input:focus-visible, .calc select:focus-visible { border-radius: var(--r-md); }
