/* ==========================================================================
   משו״ב למורה — Apple-HIG-style design system (see README "Design system")
   - Type: Heebo (Hebrew + Latin, Google Fonts). iOS type steps only.
   - Spacing: 8px step. Every gap is a multiple of --s.
   - Tap targets: 44px minimum hit region.
   - RTL: logical properties (inline-start/end) everywhere.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --brand: #7A2FD0;              /* links/focus: 6.35:1 on --bg */
  --pink-text: #B0185F;          /* accent text: 6.68:1 on white */
  --grad-a: #7C3AED;             /* white on it: 5.70:1 */
  --grad-b: #C2185B;             /* white on it: 5.87:1 */
  --grad: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  --on-grad: #FFFFFF;
  --brand-tint: rgb(122 47 208 / 0.1);

  --bg: #FBF8FF;
  --surface: #FFFFFF;
  --text: #1D1A24;               /* 16.3:1 */
  --text-2: #5F5870;             /* 6.41:1 */
  --hairline: rgb(40 0 80 / 0.1);
  --shadow: 0 1px 2px rgb(60 0 120 / 0.05), 0 8px 24px rgb(60 0 120 / 0.07);
  --nav-bg: rgb(251 248 255 / 0.72);

  /* Category tones — text variants all ≥ 5.3:1 on white */
  --orange: #B54708;
  --amber: #9A5B00;
  --red: #B42318;
  --green: #1E7A3C;
  --purple: #7A2FD0;

  /* Type scale — iOS steps */
  --t-caption: 12px;  --lh-caption: 16px;
  --t-footnote: 13px; --lh-footnote: 18px;
  --t-subhead: 15px;  --lh-subhead: 20px;
  --t-body: 17px;     --lh-body: 25px;
  --t-title3: 20px;   --lh-title3: 28px;
  --t-title1: 28px;   --lh-title1: 34px;
  --t-large: 34px;    --lh-large: 41px;
  --t-display: 48px;  --lh-display: 56px;

  --s: 8px;
  --gutter: calc(var(--s) * 2);
  --r-sm: 12px;
  --r-md: 20px;
  --r-lg: 28px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Heebo", "Arial Hebrew", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #C9A2FF;            /* 9.23:1 on --bg */
    --pink-text: #FF8CC6;        /* 8.29:1 on surface */
    --grad-a: #C9A2FF;
    --grad-b: #FF9ACF;
    --on-grad: #2A0E4F;          /* ≥ 7.9:1 on both stops */
    --brand-tint: rgb(201 162 255 / 0.14);
    --bg: #110D17;
    --surface: #1B1622;
    --text: #F5F3F8;             /* 17.4:1 */
    --text-2: #A9A1B6;           /* 7.14:1 on surface */
    --hairline: rgb(255 255 255 / 0.1);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.3);
    --nav-bg: rgb(17 13 23 / 0.72);
    --orange: #FFA36B;
    --amber: #F5C04F;
    --red: #FF8A80;
    --green: #6FD38A;
    --purple: #C9A2FF;
  }
}

@media (prefers-contrast: more) {
  :root { --text-2: var(--text); --hairline: rgb(127 127 127 / 0.6); }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; border-radius: 8px; }
code { font-size: var(--t-subhead); background: var(--brand-tint); padding: 2px 6px; border-radius: 6px; direction: ltr; unicode-bidi: embed; }

.sprite { position: absolute; }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon--sm { width: 16px; height: 16px; stroke-width: 3; }

.container {
  width: 100%;
  max-width: 1128px;
  margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-right)) max(var(--gutter), env(safe-area-inset-left));
}
.narrow { max-width: 640px; }
@media (min-width: 480px) { :root { --gutter: calc(var(--s) * 3); } }

/* ---------- Type ---------- */
.eyebrow { font-size: var(--t-subhead); line-height: var(--lh-subhead); font-weight: 600; color: var(--pink-text); margin-block-end: var(--s); }
.title { font-size: var(--t-large); line-height: var(--lh-large); font-weight: 700; letter-spacing: -0.02em; margin-block-end: calc(var(--s) * 3); }
.subtitle { font-size: var(--t-title3); line-height: var(--lh-title3); font-weight: 700; margin-block: calc(var(--s) * 5) calc(var(--s) * 2); }
.lead { font-size: var(--t-title3); line-height: var(--lh-title3); color: var(--text-2); margin-block-end: calc(var(--s) * 4); }
.title + .lead { margin-block-start: calc(var(--s) * -2); }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Nav (only glass layer) ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-block-end: 1px solid var(--hairline);
  padding-block-start: env(safe-area-inset-top);
}
.nav__inner { display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
.nav__brand { display: inline-flex; align-items: center; gap: var(--s); min-height: 44px; color: var(--text); text-decoration: none; font-weight: 700; font-size: var(--t-body); }
.nav__brand img { border-radius: 8px; }
.nav__user { display: flex; align-items: center; gap: var(--s); }
.nav__name { font-size: var(--t-subhead); color: var(--text-2); font-weight: 500; }

/* ---------- Screens ---------- */
.screen { padding-block: calc(var(--s) * 5) calc(var(--s) * 10); }
.screen--hero {
  position: relative; overflow: hidden;
  min-height: 100dvh; display: grid; place-items: center; text-align: center;
}
.glow {
  position: absolute; inset: -20% -10% auto; height: 80%;
  background:
    radial-gradient(40% 50% at 30% 40%, rgb(124 58 237 / 0.22), transparent 70%),
    radial-gradient(40% 50% at 70% 50%, rgb(236 72 153 / 0.2), transparent 70%);
  pointer-events: none;
}
.hero { position: relative; display: flex; flex-direction: column; align-items: center; }
.hero__icon { border-radius: 22px; box-shadow: 0 16px 40px rgb(124 58 237 / 0.3); margin-block-end: calc(var(--s) * 4); animation: rise 0.8s var(--ease) both; }
.hero__title { font-size: var(--t-large); line-height: var(--lh-large); font-weight: 700; letter-spacing: -0.025em; margin-block-end: calc(var(--s) * 2); }
.hero .lead { max-width: 30ch; }
@media (min-width: 768px) {
  .hero__title { font-size: var(--t-display); line-height: var(--lh-display); }
  .title { font-size: var(--t-display); line-height: var(--lh-display); }
}
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(0.96); } }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow); border: 1px solid var(--hairline); }
.stack { display: grid; gap: calc(var(--s) * 3); padding: calc(var(--s) * 3); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s);
  min-height: 44px; min-width: 44px; padding: 0 calc(var(--s) * 2.5);
  border: 0; border-radius: 999px; cursor: pointer;
  font-weight: 600; font-size: var(--t-body); text-decoration: none;
  transition: transform 0.15s var(--ease), opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: progress; }
.btn--primary { background: var(--grad); color: var(--on-grad); box-shadow: 0 8px 20px rgb(124 58 237 / 0.25); min-height: 50px; }
.btn--lg { min-height: 56px; padding-inline: calc(var(--s) * 4); font-size: var(--t-title3); }
.btn--tinted { background: var(--brand-tint); color: var(--brand); }
.btn--ghost { background: none; color: var(--brand); padding-inline: 0; }
.btn--ghost:hover { text-decoration: underline; }
.btn--icon { background: none; color: var(--text-2); padding: 0; }
.btn--icon:hover { color: var(--text); background: var(--brand-tint); }
.back { margin-block-end: var(--s); }

/* ---------- Forms ---------- */
.field { display: grid; gap: var(--s); }
.field__label { font-size: var(--t-subhead); line-height: var(--lh-subhead); font-weight: 600; color: var(--text-2); padding: 0; margin-block-end: var(--s); }
.field > .field__label { margin: 0; }
.input {
  width: 100%; min-height: 48px; padding: var(--s) calc(var(--s) * 2);
  background: var(--bg); border: 1px solid var(--hairline); border-radius: var(--r-sm);
  font-size: var(--t-body); /* 17px stops iOS zoom-on-focus */
}
.input:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.input::placeholder { color: var(--text-2); opacity: 0.8; }
.input--bare { background: none; border: 0; padding-inline: 0; }
.input--bare:focus { outline: 0; }
.textarea { resize: vertical; min-height: 96px; }
input[type="date"] { direction: rtl; }
.form-error { min-height: var(--lh-subhead); font-size: var(--t-subhead); line-height: var(--lh-subhead); color: var(--red); margin-block-start: var(--s); }
.stack .form-error { margin: 0; }
.stack .form-error:empty { display: none; }

.search {
  display: flex; align-items: center; gap: var(--s);
  min-height: 48px; padding-inline: calc(var(--s) * 2);
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-sm);
  color: var(--text-2); margin-block-end: calc(var(--s) * 2);
}
.search:focus-within { outline: 2px solid var(--brand); }

/* Lesson picker 1–8: native radios styled as a grid of pills */
.lessons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s); }
@media (min-width: 480px) { .lessons { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
.lesson { position: relative; }
.lesson input, .chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.lesson span {
  display: grid; place-items: center; min-height: 44px; border-radius: var(--r-sm);
  background: var(--bg); border: 1px solid var(--hairline); font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.lesson input:checked + span { background: var(--grad); color: var(--on-grad); border-color: transparent; }
.lesson input:focus-visible + span, .chip input:focus-visible ~ span { outline: 3px solid var(--brand); outline-offset: 2px; }

/* Category chips: native checkboxes */
.chips { display: flex; flex-wrap: wrap; gap: var(--s); }
.chip {
  --tone: var(--purple);
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding-inline: calc(var(--s) * 2);
  border-radius: 999px; border: 1.5px solid var(--hairline); background: var(--bg);
  font-weight: 500; cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip .icon { display: none; }
.chip:has(input:checked) { border-color: var(--tone); color: var(--tone); background: color-mix(in srgb, var(--tone) 10%, transparent); font-weight: 600; }
.chip:has(input:checked) .icon { display: block; }

.tone-orange { --tone: var(--orange); }
.tone-amber { --tone: var(--amber); }
.tone-red { --tone: var(--red); }
.tone-green { --tone: var(--green); }
.tone-purple { --tone: var(--purple); }

/* ---------- Teacher list ---------- */
.list { overflow: hidden; margin-block-end: calc(var(--s) * 3); }
.list li + li { border-block-start: 1px solid var(--hairline); }
.list__row {
  display: flex; align-items: center; gap: calc(var(--s) * 1.5); width: 100%;
  min-height: 64px; padding: var(--s) calc(var(--s) * 2);
  background: none; border: 0; cursor: pointer; text-align: start;
}
.list__row:hover { background: var(--brand-tint); }
.list__chev { color: var(--text-2); }
.list__empty { padding: calc(var(--s) * 3); text-align: center; color: var(--text-2); }
.avatar {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 50%; background: var(--grad); color: var(--on-grad); font-weight: 700;
}
.list__text { flex: 1; display: grid; min-width: 0; }
.list__name { font-weight: 500; }
.list__sub { font-size: var(--t-subhead); line-height: var(--lh-subhead); color: var(--text-2); }

.title-row { display: flex; align-items: center; justify-content: space-between; gap: calc(var(--s) * 2); margin-block-end: calc(var(--s) * 3); }
.title-row .title { margin: 0; }
.title-row .btn { flex: none; }

/* Add-teacher dialog: bottom sheet on phones, centered card above 640px */
.sheet {
  width: 100%; max-width: 480px; margin: auto auto 0; padding: 0;
  border: 0; border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  padding-block-end: env(safe-area-inset-bottom);
}
.sheet::backdrop { background: rgb(20 0 40 / 0.4); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.sheet[open] { animation: rise 0.35s var(--ease); }
.sheet .subtitle { margin: 0; }
.sheet__actions { display: grid; gap: var(--s); }
@media (min-width: 640px) { .sheet { margin: auto; border-radius: var(--r-lg); } }

/* ---------- Segmented control ---------- */
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px;
  background: var(--brand-tint); border-radius: 999px; margin-block-end: calc(var(--s) * 3);
}
.segmented__btn {
  min-height: 44px; border: 0; border-radius: 999px; background: none; cursor: pointer;
  font-weight: 600; font-size: var(--t-subhead); color: var(--text-2);
  transition: background 0.2s var(--ease), color 0.2s;
}
.segmented__btn[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Rating ---------- */
.score { display: grid; justify-items: center; gap: calc(var(--s) * 2); padding: calc(var(--s) * 4) calc(var(--s) * 3); }
.score__ring {
  --p: 0;
  display: grid; place-content: center; text-align: center;
  width: 168px; aspect-ratio: 1; border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--surface) 82%, transparent 83%),
    conic-gradient(from 0deg, var(--grad-a), var(--grad-b) calc(var(--p) * 1%), var(--brand-tint) 0);
  transition: --p 0.8s var(--ease);
}
@property --p { syntax: "<number>"; inherits: true; initial-value: 0; }
.score__value { font-size: var(--t-display); line-height: var(--lh-display); font-weight: 700; letter-spacing: -0.03em; }
.score__of { font-size: var(--t-footnote); line-height: var(--lh-footnote); color: var(--text-2); }
.score__meta { color: var(--text-2); font-size: var(--t-subhead); }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: calc(var(--s) * 1.5); margin-block-start: calc(var(--s) * 2); }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat {
  display: grid; grid-template-columns: 1fr auto; gap: var(--s); align-items: baseline;
  padding: calc(var(--s) * 2); background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-sm);
}
.stat__label { font-size: var(--t-subhead); font-weight: 600; color: var(--tone); }
.stat__count { font-size: var(--t-title1); line-height: var(--lh-title1); font-weight: 700; }
.stat__bar { grid-column: 1 / -1; display: flex; height: 6px; border-radius: 999px; background: var(--brand-tint); overflow: hidden; }
.stat__bar span { display: block; height: 100%; background: var(--tone); border-radius: inherit; transition: width 0.6s var(--ease); }

.reviews { display: grid; gap: calc(var(--s) * 1.5); }
.review { padding: calc(var(--s) * 2); display: grid; gap: var(--s); }
.review__head { display: flex; justify-content: space-between; align-items: center; gap: var(--s); }
.review__when { font-size: var(--t-subhead); font-weight: 600; }
.review__score { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--grad); color: var(--on-grad); font-weight: 700; font-size: var(--t-subhead); }
.review__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.review__tags:empty { display: none; }
.tag { font-size: var(--t-footnote); line-height: var(--lh-footnote); font-weight: 600; padding: 4px 10px; border-radius: 999px; color: var(--tone); background: color-mix(in srgb, var(--tone) 12%, transparent); }
.review__notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.review__by { font-size: var(--t-footnote); line-height: var(--lh-footnote); color: var(--text-2); }
.review__by:empty { display: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; inset-inline: 0; bottom: max(calc(var(--s) * 3), env(safe-area-inset-bottom));
  width: fit-content; max-width: calc(100% - 32px); margin-inline: auto; z-index: 20;
  padding: calc(var(--s) * 1.5) calc(var(--s) * 3); border-radius: 999px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: var(--t-subhead);
  opacity: 0; transform: translateY(16px); pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}
.toast:empty { display: none; }
.toast.is-shown { opacity: 1; transform: none; }

@media (hover: hover) {
  .btn--primary:hover { box-shadow: 0 12px 28px rgb(124 58 237 / 0.35); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
.guest { margin-block-start: calc(var(--s) * 2); }
