/* ============================================================
   AHMAD'S PATH TO MEDICINE — "Damascene Dawn" design system
   Warm editorial dashboard · subtle Levantine geometry
   Fonts: Fraunces (display) · Instrument Sans (body) · Amiri (Arabic accent)
   ============================================================ */

:root {
  /* Palette — Damascus tilework & apricot orchards */
  --sand: #F7F1E5;          /* page background */
  --sand-deep: #EFE6D3;     /* alt band */
  --paper: #FFFDF7;         /* cards */
  --ink: #27332E;           /* primary text — deep olive charcoal */
  --ink-soft: #55625B;      /* secondary text */
  --ink-faint: #8B958E;     /* tertiary / meta */
  --olive: #3E5C50;         /* deep Damascus green */
  --olive-tint: #E3EAE2;
  --terracotta: #C05B33;    /* primary accent */
  --terracotta-deep: #A34724;
  --terracotta-tint: #F6E3D8;
  --amber: #D9A441;         /* gold accent */
  --amber-tint: #F7ECD4;
  --rose: #A94F5C;          /* Damask rose — sparing */
  --rose-tint: #F3E2E2;
  --line: #E2D8C4;          /* hairlines */
  --shadow: 0 1px 2px rgba(62, 60, 45, .06), 0 8px 24px -12px rgba(62, 60, 45, .18);
  --shadow-lift: 0 2px 4px rgba(62, 60, 45, .07), 0 16px 36px -14px rgba(62, 60, 45, .26);
  --radius: 14px;
  --radius-sm: 9px;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Instrument Sans", "Segoe UI", sans-serif;
  --font-arabic: "Amiri", serif;

  --sidebar-w: 248px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--sand);
  /* Khatam 8-point star lattice — whisper quiet */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%233E5C50' stroke-opacity='0.05' stroke-width='1'%3E%3Cpath d='M48 18 L56.5 39.5 L78 48 L56.5 56.5 L48 78 L39.5 56.5 L18 48 L39.5 39.5 Z'/%3E%3Cpath d='M48 27 L63 33 L69 48 L63 63 L48 69 L33 63 L27 48 L33 33 Z'/%3E%3C/g%3E%3C/svg%3E");
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--amber-tint); color: var(--terracotta-deep); }

/* ---------- Type scale ---------- */
h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
}
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.7rem); }
h3 { font-size: 1.12rem; }
p  { color: var(--ink-soft); }
a  { color: var(--terracotta-deep); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
strong { color: var(--ink); }

.eyebrow {
  font-size: .72rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--terracotta);
  display: flex; align-items: center; gap: .5rem;
}
.eyebrow::before {
  content: ""; width: 18px; height: 1px; background: var(--terracotta); opacity: .6;
}

.arabic-accent {
  font-family: var(--font-arabic);
  color: var(--olive);
  font-size: 1.25em;
  opacity: .85;
}

/* ---------- Layout shell ---------- */
.shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(178deg, #2E463D 0%, #27332E 100%);
  color: #EDE7D8;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 1.6rem 1.1rem 1.1rem;
  overflow-y: auto;
  scrollbar-width: thin;
  z-index: 40;
}
.sidebar::after { /* ajami hairline on the edge */
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 3px;
  background: repeating-linear-gradient(180deg, var(--amber) 0 10px, transparent 10px 20px);
  opacity: .35;
}
.brand { display: flex; align-items: center; gap: .7rem; padding: 0 .55rem 1.2rem; }
.brand-star { width: 34px; height: 34px; flex-shrink: 0; }
.brand-name {
  font-family: var(--font-display); font-size: 1.02rem; font-weight: 600;
  line-height: 1.25; color: #F5EFDF;
}
.brand-name small {
  display: block; font-family: var(--font-body); font-weight: 500;
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  color: #C9BFA4; margin-top: 2px;
}

.nav-group-label {
  font-size: .64rem; letter-spacing: .16em; text-transform: uppercase;
  color: #9FAF9F; padding: 1rem .6rem .35rem; font-weight: 700;
}
.nav-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .5rem .6rem; margin: 1px 0;
  border-radius: var(--radius-sm);
  color: #D9D2BE; font-size: .9rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 253, 247, .07); color: #fff; text-decoration: none; }
.nav-link.active {
  background: var(--terracotta); color: #FFF8F2;
  box-shadow: 0 4px 14px -6px rgba(192, 91, 51, .7);
}
.nav-link .icon { width: 17px; height: 17px; flex-shrink: 0; opacity: .9; }

.sidebar-foot {
  margin-top: auto; padding: 1rem .6rem 0; font-size: .75rem; color: #9FAF9F;
  border-top: 1px solid rgba(237, 231, 216, .12);
}
.sidebar-foot .arabic-accent { color: var(--amber); display: block; font-size: 1.05rem; margin-bottom: .2rem; }

/* Topbar (mobile) */
.topbar {
  display: none;
  position: sticky; top: 0; z-index: 50;
  background: #27332E; color: #F5EFDF;
  padding: .7rem 1rem;
  align-items: center; justify-content: space-between;
}
.topbar .brand { padding: 0; }
.menu-btn {
  background: none; border: 1px solid rgba(245, 239, 223, .3); color: #F5EFDF;
  border-radius: 8px; padding: .38rem .6rem; font-size: 1rem; cursor: pointer;
}

/* Main column */
.main { flex: 1; min-width: 0; padding: 2.2rem clamp(1.1rem, 4vw, 3rem) 4rem; }
.page-head { margin-bottom: 1.8rem; max-width: 860px; }
.page-head h1 { margin: .45rem 0 .6rem; }
.page-head .lede { font-size: 1.06rem; max-width: 62ch; }

/* ---------- Cards ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card.hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.card h3 { margin-bottom: .4rem; }
.card-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); }
.card .meta { font-size: .78rem; color: var(--ink-faint); }

.card-accent { border-top: 3px solid var(--terracotta); }
.card-olive  { border-top: 3px solid var(--olive); }
.card-amber  { border-top: 3px solid var(--amber); }

/* Stat tiles (dashboard) */
.stat {
  display: flex; flex-direction: column; gap: .15rem;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow);
}
.stat .num { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; color: var(--terracotta-deep); }
.stat .label { font-size: .78rem; color: var(--ink-soft); font-weight: 600; letter-spacing: .02em; }

/* Callouts */
.callout {
  border-radius: var(--radius);
  padding: 1.05rem 1.25rem;
  border: 1px solid;
  margin: 1.1rem 0;
  font-size: .95rem;
}
.callout.warm { background: var(--terracotta-tint); border-color: #E7C4AF; color: #6B3B22; }
.callout.calm { background: var(--olive-tint); border-color: #C4D2C2; color: #2F4A3E; }
.callout.gold { background: var(--amber-tint); border-color: #E6D3A3; color: #6E5320; }
.callout strong:first-child { display: block; margin-bottom: .2rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; font-size: .68rem; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase;
  border-radius: 100px; padding: .18rem .6rem; white-space: nowrap;
}
.badge.fit-strong { background: var(--olive-tint); color: #2F4A3E; }
.badge.fit-good   { background: var(--amber-tint); color: #6E5320; }
.badge.fit-stretch{ background: var(--rose-tint); color: #7A3844; }
.badge.neutral    { background: var(--sand-deep); color: var(--ink-soft); }
.badge.gpa-none   { background: var(--olive-tint); color: #2F4A3E; }
.badge.paid       { background: var(--terracotta-tint); color: #6B3B22; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--font-body); font-weight: 600; font-size: .9rem;
  border-radius: 100px; padding: .58rem 1.25rem;
  border: none; cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s;
}
.btn-primary { background: var(--terracotta); color: #FFF8F2; box-shadow: 0 6px 18px -8px rgba(192, 91, 51, .8); }
.btn-primary:hover { background: var(--terracotta-deep); transform: translateY(-1px); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--olive); border: 1.5px solid var(--olive); }
.btn-ghost:hover { background: var(--olive-tint); text-decoration: none; }
.btn-small { padding: .34rem .85rem; font-size: .8rem; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 640px; }
thead th {
  text-align: left; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 700;
  padding: .8rem .9rem; border-bottom: 2px solid var(--line);
  background: var(--sand-deep); position: sticky; top: 0;
}
tbody td { padding: .75rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-soft); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FBF7EC; }
td strong, td a { font-weight: 600; }

/* ---------- Filters ---------- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: .55rem; align-items: center;
  margin: 1rem 0 1.1rem;
}
.search-input {
  flex: 1 1 220px; max-width: 340px;
  font-family: var(--font-body); font-size: .9rem;
  padding: .55rem .95rem; border-radius: 100px;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.search-input:focus { border-color: var(--terracotta); box-shadow: 0 0 0 3px var(--terracotta-tint); }
.chip {
  font-family: var(--font-body); font-size: .8rem; font-weight: 600;
  padding: .4rem .9rem; border-radius: 100px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink-soft);
  transition: all .15s;
}
.chip:hover { border-color: var(--olive); color: var(--olive); }
.chip.on { background: var(--olive); border-color: var(--olive); color: #F2F0E4; }
.filter-count { font-size: .8rem; color: var(--ink-faint); margin-left: auto; }

/* ---------- Checklists ---------- */
.checklist { list-style: none; display: flex; flex-direction: column; gap: .45rem; }
.check-item {
  display: flex; gap: .7rem; align-items: flex-start;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .68rem .9rem; cursor: pointer; transition: background .15s;
  font-size: .92rem; color: var(--ink-soft);
}
.check-item:hover { background: #FBF7EC; }
.check-item input { margin-top: .25rem; accent-color: var(--terracotta); width: 15px; height: 15px; flex-shrink: 0; cursor: pointer; }
.check-item.done { opacity: .6; }
.check-item.done .check-label { text-decoration: line-through; }

/* Progress */
.progress-track {
  height: 9px; border-radius: 100px; background: var(--sand-deep);
  overflow: hidden; border: 1px solid var(--line);
}
.progress-fill {
  height: 100%; border-radius: 100px;
  background: linear-gradient(90deg, var(--olive), var(--amber));
  transition: width .5s ease;
}

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 1.7rem; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px;
  background: repeating-linear-gradient(180deg, var(--amber) 0 8px, var(--line) 8px 16px);
}
.tl-item { position: relative; padding: 0 0 1.5rem; }
.tl-item::before {
  content: ""; position: absolute; left: -1.7rem; top: 6px;
  width: 12px; height: 12px; transform: rotate(45deg);
  background: var(--terracotta); border: 2px solid var(--paper);
  box-shadow: 0 0 0 1.5px var(--terracotta);
}
.tl-item h3 { color: var(--terracotta-deep); margin-bottom: .3rem; }
.tl-item .when { font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }

/* ---------- Accordion ---------- */
details.acc {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: .7rem; box-shadow: var(--shadow); overflow: hidden;
}
details.acc summary {
  cursor: pointer; padding: 1rem 1.25rem; font-weight: 600; color: var(--ink);
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary::after {
  content: "+"; font-family: var(--font-display); font-size: 1.25rem; color: var(--terracotta);
  transition: transform .2s;
}
details.acc[open] summary::after { transform: rotate(45deg); }
details.acc .acc-body { padding: 0 1.25rem 1.15rem; font-size: .93rem; color: var(--ink-soft); }

/* ---------- Sections / dividers ---------- */
.section { margin: 2.4rem 0; }
.section > h2 { margin-bottom: .95rem; display: flex; align-items: baseline; gap: .7rem; }
.divider-star {
  display: flex; align-items: center; gap: .9rem; margin: 2.6rem 0;
  color: var(--amber);
}
.divider-star::before, .divider-star::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.divider-star svg { width: 16px; height: 16px; opacity: .8; }

/* ---------- Email / code blocks (templates) ---------- */
.template-block {
  background: #FBF8F0; border: 1px dashed #D3C6A8; border-radius: var(--radius);
  padding: 1.15rem 1.3rem; font-size: .9rem; color: var(--ink-soft);
  white-space: pre-wrap; line-height: 1.65; position: relative;
  font-family: var(--font-body);
}
.copy-btn {
  position: absolute; top: .7rem; right: .7rem;
  font-size: .72rem; font-weight: 700; padding: .28rem .7rem;
  border-radius: 100px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink-soft); cursor: pointer;
}
.copy-btn:hover { border-color: var(--terracotta); color: var(--terracotta); }

/* ---------- Forms (trackers) ---------- */
.field { display: flex; flex-direction: column; gap: .25rem; }
.field label { font-size: .76rem; font-weight: 700; color: var(--ink-soft); letter-spacing: .03em; }
.field input, .field select, .field textarea {
  font-family: var(--font-body); font-size: .9rem; color: var(--ink);
  padding: .5rem .75rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--paper); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--terracotta); box-shadow: 0 0 0 3px var(--terracotta-tint);
}
.form-row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; margin-bottom: 1rem; }
.form-row .field { flex: 1 1 150px; }

/* ---------- Hero (dashboard) ---------- */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(120deg, #33473E 0%, #3E5C50 55%, #4A6A54 100%);
  color: #F2EDDD;
  border-radius: 20px;
  padding: clamp(1.8rem, 4vw, 3rem);
  margin-bottom: 1.6rem;
  box-shadow: var(--shadow-lift);
}
.hero::before { /* large khatam star, barely-there */
  content: ""; position: absolute; right: -70px; top: -70px; width: 340px; height: 340px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%23D9A441' stroke-opacity='0.28' stroke-width='0.8'%3E%3Cpath d='M48 6 L60 36 L90 48 L60 60 L48 90 L36 60 L6 48 L36 36 Z'/%3E%3Cpath d='M48 20 L68 28 L76 48 L68 68 L48 76 L28 68 L20 48 L28 28 Z'/%3E%3Ccircle cx='48' cy='48' r='10'/%3E%3C/g%3E%3C/svg%3E") no-repeat center / contain;
  animation: slowspin 90s linear infinite;
}
@keyframes slowspin { to { transform: rotate(360deg); } }
.hero h1 { color: #FBF7EA; }
.hero .lede { color: #D8D3BC; max-width: 58ch; font-size: 1.03rem; }
.hero .arabic-accent { color: var(--amber); font-size: 1.5rem; }
.hero-cta { margin-top: 1.3rem; display: flex; gap: .7rem; flex-wrap: wrap; }
.hero .btn-ghost { border-color: #C9BFA4; color: #EDE7D8; }
.hero .btn-ghost:hover { background: rgba(255,255,255,.08); }

/* ---------- Load-in animation ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .55s cubic-bezier(.2,.7,.3,1) both; }
.rise-1 { animation-delay: .05s; } .rise-2 { animation-delay: .12s; }
.rise-3 { animation-delay: .19s; } .rise-4 { animation-delay: .26s; }
.rise-5 { animation-delay: .33s; } .rise-6 { animation-delay: .4s; }
@media (prefers-reduced-motion: reduce) {
  .rise, .rise-1, .rise-2, .rise-3, .rise-4, .rise-5, .rise-6 { animation: none; }
  .hero::before { animation: none; }
}

/* ---------- Utility ---------- */
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.mt-1 { margin-top: .6rem; } .mt-2 { margin-top: 1.2rem; } .mb-1 { margin-bottom: .6rem; }
.muted { color: var(--ink-faint); font-size: .84rem; }
.hidden { display: none !important; }
ul.styled { padding-left: 1.15rem; color: var(--ink-soft); }
ul.styled li { margin-bottom: .4rem; }
ul.styled li::marker { color: var(--terracotta); }
ol.styled { padding-left: 1.25rem; color: var(--ink-soft); }
ol.styled li { margin-bottom: .45rem; }
ol.styled li::marker { color: var(--terracotta); font-weight: 700; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .topbar { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-105%); transition: transform .25s ease;
    height: 100vh; box-shadow: 0 0 60px rgba(0,0,0,.35);
  }
  .sidebar.open { transform: none; }
  .main { padding-top: 1.4rem; }
  .scrim {
    position: fixed; inset: 0; background: rgba(30, 36, 32, .45);
    opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 30;
  }
  .scrim.show { opacity: 1; pointer-events: auto; }
}
@media (min-width: 901px) { .topbar, .scrim { display: none; } }

/* print — let Ahmad print checklists cleanly */
@media print {
  .sidebar, .topbar, .filter-bar, .btn, .copy-btn { display: none !important; }
  body { background: #fff; }
  .card, .table-wrap { box-shadow: none; }
}

/* ============================================================
   RTL / ARABIC LAYER (appended 2026-07-06)
   Arabic pages set <html lang="ar" dir="rtl"> and live in /ar/.
   Fonts: Amiri (display) · IBM Plex Sans Arabic (body)
   ============================================================ */
html[lang="ar"] body {
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  line-height: 1.75;
}
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3,
html[lang="ar"] .display, html[lang="ar"] .brand-name,
html[lang="ar"] .stat .num, html[lang="ar"] details.acc summary::after {
  font-family: "Amiri", serif;
  letter-spacing: 0;
}
html[lang="ar"] .eyebrow { letter-spacing: .02em; }
html[lang="ar"] thead th { letter-spacing: .02em; }

/* Directional flips */
[dir="rtl"] .sidebar::after { right: auto; left: 0; }
[dir="rtl"] .timeline { padding-left: 0; padding-right: 1.7rem; }
[dir="rtl"] .timeline::before { left: auto; right: 7px; }
[dir="rtl"] .tl-item::before { left: auto; right: -1.7rem; }
[dir="rtl"] thead th, [dir="rtl"] tbody td { text-align: right; }
[dir="rtl"] .filter-count { margin-left: 0; margin-right: auto; }
[dir="rtl"] .copy-btn { right: auto; left: .7rem; }
[dir="rtl"] .hero::before { right: auto; left: -70px; }
[dir="rtl"] ul.styled, [dir="rtl"] ol.styled { padding-left: 0; padding-right: 1.25rem; }
@media (max-width: 900px) {
  [dir="rtl"] .sidebar { left: auto; right: 0; transform: translateX(105%); }
  [dir="rtl"] .sidebar.open { transform: none; }
}

/* Latin terms embedded in Arabic text (AMCAS, MCAT, org names) */
html[lang="ar"] .ltr-term {
  direction: ltr; unicode-bidi: isolate; display: inline-block;
  font-family: "Instrument Sans", sans-serif; font-size: .95em;
}

/* Language toggle */
.lang-toggle {
  display: inline-flex; align-items: center; gap: .4rem;
  margin: .35rem .55rem .9rem;
  padding: .34rem .9rem; border-radius: 100px;
  border: 1px solid rgba(217, 164, 65, .55);
  color: #EDE7D8; font-size: .8rem; font-weight: 600;
  background: rgba(217, 164, 65, .12);
  transition: background .15s;
  width: fit-content;
}
.lang-toggle:hover { background: rgba(217, 164, 65, .25); text-decoration: none; color: #fff; }
.topbar .lang-toggle { margin: 0 .6rem; }
