/*
  פרשת השבוע, עיצוב בסיס עצמאי (מחולץ מהאפליקציה "האהל": אבן גיר, דיו של בזלת, גפן לקישורים ולמצב פעיל).
  גופן אחד (Rubik) מתוך הקבצים המקומיים, כך שהכול עובד גם בלי רשת. כל הכיוונים לוגיים (RTL).
*/
@font-face { font-family: 'Rubik'; font-weight: 300 900; font-display: swap; src: url(../fonts/Rubik-Variable.ttf) format('truetype'); }
@font-face { font-family: 'Heebo'; font-weight: 100 900; font-display: swap; src: url(../fonts/Heebo-Variable.ttf) format('truetype'); }
/* הכתב העברי העתיק (פיניקי), לשימוש המילים בתצוגת כתב עתיק */
@font-face { font-family: 'Ohel Ivri'; font-display: swap; src: url(../fonts/phoenician.woff2) format('woff2'); unicode-range: U+10900-1091F; }

:root {
  --z-bar: 12; --z-float: 30; --z-bubble: 40; --z-menu: 50; --z-sheet: 60; --z-toast: 70;
  --chalk: #efeee6;
  --chalk-raised: #f7f6f0;
  --ink: #2e2a1e;
  --vine: #55622f;
  --olive: #c2b04e;
  --soil: #9c7a55;
  --tint: #dceaf1;

  --bg: var(--chalk);
  --card: var(--chalk-raised);
  --text: var(--ink);
  --muted: #625a45;
  --line: #dcd8c9;
  --line-strong: #c9c4b1;
  --primary: var(--vine);
  --primary-ink: #f7f6f0;
  --accent: var(--olive);
  --accent-ink: var(--ink);
  --danger: #9a3b2a;
  --ok: var(--vine);
  --glass-border: rgba(46, 42, 30, 0.12);
  --lift: 0 1px 0 rgba(46, 42, 30, .04), 0 10px 30px rgba(46, 42, 30, .10);
  --radius: 12px;
  --radius-sm: 9px;
  --radius-lg: 20px;

  --appbar-h: 0px;
  --ease-river: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-leave: cubic-bezier(0.4, 0, 1, 1);
  --dur-press: 120ms;
  --dur-quick: 200ms;
  --dur-draw: 340ms;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
    --bg: #070b14; --card: #0e1422; --text: #dfd9cb; --muted: #a9afbd; --line: #1a2335; --line-strong: #28344c;
    --primary: #a8c28c; --primary-ink: #070b14; --danger: #e79a85; --ok: #a8c28c;
    --glass-border: rgba(231, 225, 211, 0.10); --lift: 0 10px 30px rgba(0, 0, 0, .45); --tint: #14203a;
    color-scheme: dark;
  } }
:root[data-theme="dark"] {
    --bg: #070b14; --card: #0e1422; --text: #dfd9cb; --muted: #a9afbd; --line: #1a2335; --line-strong: #28344c;
    --primary: #a8c28c; --primary-ink: #070b14; --danger: #e79a85; --ok: #a8c28c;
    --glass-border: rgba(231, 225, 211, 0.10); --lift: 0 10px 30px rgba(0, 0, 0, .45); --tint: #14203a;
    color-scheme: dark;
  }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; background: var(--bg); overflow-x: clip; }
body { overflow-x: clip; }
body {
  margin: 0;
  font-family: 'Rubik', 'Heebo', system-ui, -apple-system, 'Segoe UI', Arial, 'Ohel Ivri', sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  min-block-size: 100dvh;
  padding-block-end: env(safe-area-inset-bottom);
  text-rendering: optimizeLegibility;
}
::selection { background: var(--tint); color: var(--ink); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
h1, h2, h3 { font-weight: 500; text-wrap: balance; letter-spacing: -0.005em; }
p { text-wrap: pretty; }
a { color: var(--primary); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
body.modal-open { overflow: hidden; }
main { max-width: 760px; margin: 0 auto; padding: 0 16px 96px; }
main.wide { max-width: 1200px; }
button, input, select, textarea { font-family: inherit; }
:where(a, button, [role="button"], [role="tab"], summary, label, .chip, .btn) { touch-action: manipulation; }

.icon { inline-size: 20px; block-size: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 14px 0; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hint { flex-basis: 100%; color: var(--muted); font-size: .85rem; min-height: 1.1em; }
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- forms ---------- */
input[type="text"], input[type="search"], input[type="url"], input[type="email"], select, textarea {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--card);
  border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 10px 12px; min-width: 0;
  transition: border-color var(--dur-quick) var(--ease-river), box-shadow var(--dur-quick) var(--ease-river);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: inset 0 -2px 0 var(--primary); }
textarea { width: 100%; resize: vertical; }
.field { display: grid; gap: 4px; margin: 10px 0; }
.field > span { font-size: .85rem; color: var(--muted); }
.field input, .field select { width: 100%; }

.btn {
  font: inherit; font-size: .98rem; font-weight: 500; cursor: pointer; border: 1px solid transparent; border-radius: var(--radius);
  padding: 10px 16px; background: transparent; color: var(--text); white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
  transition: background-color var(--dur-quick) var(--ease-river), border-color var(--dur-quick) var(--ease-river), color var(--dur-quick) var(--ease-river), transform var(--dur-press) var(--ease-river);
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--primary) 88%, var(--ink)); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { border-color: var(--line-strong); }
.btn:where(:not(.primary, .accent, .ghost, .ai-up)) { background: color-mix(in srgb, var(--text) 6%, var(--card)); border-color: color-mix(in srgb, var(--text) 14%, transparent); }
.btn:where(:not(.primary, .accent, .ghost, .ai-up)):hover { background: color-mix(in srgb, var(--text) 10%, var(--card)); border-color: var(--primary); }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.small { padding: 6px 12px; font-size: .88rem; }
.btn:disabled { opacity: .55; cursor: default; }

.chip { font: inherit; font-size: .88rem; cursor: pointer; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card); color: var(--text); padding: 5px 12px; transition: border-color var(--dur-quick), transform var(--dur-press) var(--ease-river); }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip[aria-pressed="true"], .chip[aria-checked="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: var(--z-toast); inset-block-start: calc(env(safe-area-inset-top, 0px) + 8px);
  inset-inline: 0; margin-inline: auto;
  display: flex; gap: 10px; align-items: center; box-sizing: border-box;
  inline-size: max-content; max-inline-size: min(480px, calc(100% - 32px)); min-block-size: 40px; padding: 8px 18px;
  border-radius: 22px; font-size: .9rem; line-height: 1.35; color: var(--text);
  background: color-mix(in srgb, var(--card) 66%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--glass-border); box-shadow: 0 6px 22px rgba(0, 0, 0, .12);
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none; pointer-events: none;
  opacity: 0; transform: translateY(calc(-100% - 16px));
  transition: transform var(--dur-draw) var(--ease-river), translate var(--dur-draw) var(--ease-river), opacity 220ms ease;
}
.toast > span { min-inline-size: 0; }
.toast.show { pointer-events: auto; opacity: 1; transform: none; }
.toast.dragging { transition: none; }
.toast .btn { flex: none; min-block-size: 32px; padding: 4px 12px; border-radius: 999px; font-weight: 600;
  color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); border: 0; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .toast { background: var(--card); } }
@media (prefers-reduced-motion: reduce) { .toast { transform: none; transition: opacity 160ms linear; } }

/* ---------- motion ---------- */
@keyframes arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wait-show { from { opacity: 0; } }
@keyframes skel-sheen { to { transform: translateX(-100%); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96); } }
@keyframes pop-out { to { opacity: 0; transform: scale(.97); } }
@keyframes fade-out { to { opacity: 0; } }
.spinner { animation: spin .8s linear infinite, wait-show var(--dur-quick) ease 400ms both; }
.loading > :not(.spinner) { animation: wait-show var(--dur-quick) ease 400ms both; }
.skel { position: relative; overflow: hidden; border-radius: 10px; background: color-mix(in srgb, var(--text) 7%, transparent); color: transparent; user-select: none; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--card) 55%, transparent), transparent); animation: skel-sheen 1.4s ease-in-out infinite; }
.skel.line { block-size: .9em; margin-block: .35em; inline-size: var(--w, 100%); }
.skel.round { border-radius: 50%; }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; opacity: 0; } }
.arrive > * { animation: arrive var(--dur-draw) var(--ease-river) both; animation-delay: calc(min(var(--i, 0), 8) * 28ms); }
.swap-in { animation: fade var(--dur-quick) ease both; }

/* ---------- AI (מוצג רק כשמוגדרת נקודת קצה, ראו js/config.js) ---------- */
.ai-pair { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.btn.ai-up { background: color-mix(in srgb, var(--accent) 22%, var(--card)); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); color: var(--text); }
.btn.ai-up:hover { background: color-mix(in srgb, var(--accent) 34%, var(--card)); border-color: var(--accent); }
.ai-note { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 6px 0 0; font-size: .82rem; color: var(--muted); }
.ai-note button { font: inherit; border: 0; background: none; padding: 0; color: var(--primary); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- סרגל עליון של האפליקציה ---------- */
.app-top { display: flex; align-items: center; gap: 10px; padding-block: calc(10px + env(safe-area-inset-top)) 6px; }
.app-top h1 { margin: 0; font-size: 1.35rem; flex: 1; }
.app-top img { inline-size: 32px; block-size: 32px; border-radius: 8px; }
[hidden] { display: none !important; }
.app-foot { margin-block: 28px calc(24px + env(safe-area-inset-bottom)); text-align: center; display: grid; gap: 10px; justify-items: center; }
.app-foot p { margin: 0; font-size: .85rem; }
.offline-pill { font-size: .8rem; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--danger) 14%, var(--card)); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
