/* ============================================================
   קלפי השראה — design system
   Two themes: "linen" (day, light) · "twilight" (night, dark)
   Vibe: workshop / contemplative / spiritual. NOT like lishkod.
   ============================================================ */

/* ---- fonts (bundled, offline-ready) ---- */
@font-face{
  font-family:'Frank';                 /* warm literary Hebrew serif — for quotes/titles */
  font-weight:400; font-display:swap;
  src:local('Taamey Frank CLM'),url('../fonts/TaameyFrankCLM-Medium.ttf') format('truetype');
}
@font-face{
  font-family:'Frank'; font-weight:700; font-display:swap;
  src:local('Taamey Frank CLM Bold'),url('../fonts/TaameyFrankCLM-Bold.ttf') format('truetype');
}
@font-face{
  font-family:'Assist';                /* modern humanist sans — for UI */
  font-weight:200 800; font-display:swap;
  src:local('Assistant'),url('../fonts/Assistant-VF.ttf') format('truetype-variations');
}
@font-face{
  font-family:'Keter';                 /* elegant classic Hebrew — poem font option */
  font-weight:400; font-display:swap;
  src:local('Keter YG'),url('../fonts/KeterYG-Medium.ttf') format('truetype');
}
@font-face{
  font-family:'STAM';                  /* traditional scribal (כתב סת"ם) — poem font option */
  font-weight:400; font-display:swap;
  src:local('Shlomo SemiStam'),url('../fonts/ShlomoSemiStam.ttf') format('truetype');
}
@font-face{
  font-family:'Handwrite';             /* אור רינת זיגדון — כתב יד לשירים (ברירת מחדל) */
  font-weight:400; font-display:swap;
  src:local('Ohr Rinat Zigdon'),
      url('../fonts/OHRinatZigdon-Regular.woff2') format('woff2'),
      url('../fonts/OHRinatZigdon-Regular.woff') format('woff'),
      url('../fonts/OHRinatZigdon-Regular.otf') format('opentype');
}

/* ===================== THEME TOKENS ===================== */
:root{
  --text-scale:1;
  --serif:'Frank','David Libre','Narkisim',serif;
  --sans:'Assist','Heebo','Segoe UI',system-ui,sans-serif;
  --poem-font:'Handwrite','Frank',serif;   /* user-switchable: handwriting (default) / square */
  --r-lg:26px; --r-md:18px; --r-sm:12px;
  --maxw:520px;
  --ease:cubic-bezier(.22,.61,.36,1);
}

/* ---- LINEN (day) ---- */
[data-theme="linen"]{
  --bg:#f2ebdd;
  --bg-grad:linear-gradient(180deg,#f6f0e4 0%,#ece2d0 100%);
  --surface:#fbf7ee;
  --surface-2:#f0e7d6;
  --ink:#3a352d;
  --ink-soft:#6f6558;
  --muted:#9a9082;
  --line:rgba(120,100,80,.16);
  --accent:#c47a5a;          /* terracotta */
  --accent-ink:#fbf6ee;
  --accent-2:#8a9a7b;        /* sage */
  --accent-3:#7d6b82;        /* dusty plum */
  --card-shadow:0 18px 44px -20px rgba(120,95,70,.55);
  --glow:none;
  --overlay:rgba(58,45,35,.5);
  --scrim:linear-gradient(0deg,rgba(30,22,14,.62) 0%,rgba(30,22,14,.15) 45%,transparent 72%);
}

/* ---- TWILIGHT (night) ---- */
[data-theme="twilight"]{
  --bg:#171019;
  --bg-grad:radial-gradient(130% 90% at 50% -8%,#3f2942 0%,#241830 42%,#150e1c 100%);
  --surface:#241a2c;
  --surface-2:#2e2138;
  --ink:#f3e9dd;
  --ink-soft:#c9b6c4;
  --muted:#9d86a0;
  --line:rgba(231,199,155,.15);
  --accent:#d9a86c;          /* warm gold */
  --accent-ink:#2a1d30;
  --accent-2:#c98a9b;        /* dusty rose */
  --accent-3:#9d86a0;
  --card-shadow:0 0 60px -14px rgba(217,168,108,.4);
  --glow:0 0 50px -8px rgba(217,168,108,.35);
  --overlay:rgba(10,6,14,.55);
  --scrim:linear-gradient(0deg,rgba(10,6,16,.72) 0%,rgba(10,6,16,.2) 48%,transparent 74%);
}

/* ===================== BASE ===================== */
*{ box-sizing:border-box; margin:0; padding:0; -webkit-tap-highlight-color:transparent; }
html,body{ height:100%; }
body{
  font-family:var(--sans);
  color:var(--ink);
  background:var(--bg);
  background-image:var(--bg-grad);
  background-attachment:scroll;
  font-size:calc(16px*var(--text-scale));
  line-height:1.5;
  overflow-x:hidden;
  -webkit-font-smoothing:antialiased;
}
.serif{ font-family:var(--serif); }
button{ font-family:inherit; color:inherit; cursor:pointer; border:none; background:none; }
a{ color:inherit; }
img{ max-width:100%; display:block; }
.sr-only{ position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); }

.app{
  max-width:var(--maxw);
  margin:0 auto;
  padding:22px 20px calc(96px + env(safe-area-inset-bottom));
  min-height:100%;
}

/* ===================== TYPOGRAPHY ===================== */
.eyebrow{ font-size:12px; letter-spacing:.16em; color:var(--muted); }
.h1{ font-family:var(--serif); font-weight:700; font-size:30px; line-height:1.2; }
.h2{ font-family:var(--serif); font-weight:700; font-size:22px; line-height:1.25; }
.subtle{ color:var(--ink-soft); }
.center{ text-align:center; }

/* ===================== TOP BAR ===================== */
.topbar{ display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; }
.topbar .brand{ display:flex; align-items:center; gap:9px; font-family:var(--serif); font-weight:700; font-size:19px; }
.topbar .brand .mark{ width:26px; height:26px; }
.topbar .date{ font-size:13px; color:var(--muted); }
.iconbtn{ width:40px; height:40px; border-radius:50%; display:grid; place-items:center;
  color:var(--ink-soft); transition:background .2s; }
.iconbtn:hover{ background:var(--surface-2); }
.iconbtn svg{ width:22px; height:22px; }

/* ===================== BUTTONS ===================== */
.btn{ display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:14px 20px; border-radius:var(--r-md); font-weight:700; font-size:15px;
  transition:transform .12s var(--ease), filter .2s, box-shadow .2s; width:100%; }
.btn:active{ transform:scale(.97); }
.btn-primary{ background:var(--accent); color:var(--accent-ink);
  box-shadow:0 12px 26px -12px var(--accent); }
.btn-ghost{ background:var(--surface); color:var(--ink); box-shadow:inset 0 0 0 1px var(--line); }
.btn-quiet{ background:transparent; color:var(--ink-soft); box-shadow:inset 0 0 0 1px var(--line); }
.btn-row{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }

/* ===================== CARD (flip) ===================== */
.card-stage{ perspective:1400px; width:100%; }
.card{
  position:relative; width:100%; aspect-ratio:5/7; border-radius:var(--r-lg);
  transform-style:preserve-3d; transition:transform .7s var(--ease);
  box-shadow:var(--card-shadow);
}
.card.is-flipped{ transform:rotateY(180deg); }
.card .face{
  position:absolute; inset:0; border-radius:var(--r-lg); overflow:hidden;
  backface-visibility:hidden; -webkit-backface-visibility:hidden;
  display:flex; flex-direction:column;
}
.card .face.back{ transform:rotateY(180deg); }

/* image face */
.face-image{ background:var(--surface-2); }
.face-image .art{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.face-image .scrim{ position:absolute; inset:0; background:var(--scrim); }
.face-image .cap{ position:relative; margin-top:auto; padding:20px; z-index:2; }
.face-image .cap .kw{ font-family:var(--serif); font-size:13px; letter-spacing:.14em;
  color:#f3e6cf; opacity:.9; margin-bottom:4px; }
.face-image .heart{ position:absolute; top:14px; left:14px; z-index:3; width:40px; height:40px;
  border-radius:50%; display:grid; place-items:center; background:var(--overlay);
  color:#fff; backdrop-filter:blur(4px); }
.face-image .heart.on{ color:#ff6b7a; }

/* live poem face — background image (supplied) + live switchable-font text on top */
.poem-live{ position:absolute; inset:0; background:var(--surface); }
.poem-live .bg{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
/* soft light veil so the (dark) live text always reads over the watercolour */
.poem-live::after{ content:''; position:absolute; inset:0; z-index:1; pointer-events:none;
  background:radial-gradient(ellipse 78% 60% at 50% 48%, rgba(252,248,240,.62), rgba(252,248,240,.12) 72%, transparent); }
.poem-live .poem-wrap{ position:absolute; inset:0; z-index:2; display:flex; flex-direction:column;
  align-items:center; justify-content:center; text-align:center; padding:30px 26px; gap:14px; }
.poem-live .poem-title{ font-family:var(--poem-font); font-size:22px; font-weight:700; color:var(--poem-ink,#2f2a22);
  background:var(--poem-title-bg, rgba(140,200,220,.55)); padding:2px 12px; border-radius:4px; }
.poem-live .poem-body{ font-family:var(--poem-font); font-size:20px; line-height:1.75; color:var(--poem-ink,#2f2a22);
  white-space:pre-line; }
.poem-live .cat-strip{ position:absolute; top:0; left:0; right:0; height:5px; z-index:3; opacity:.9; }

.flip-hint{ text-align:center; font-size:12.5px; color:var(--muted); margin-top:12px; }

/* category label + related cards (below single-card view) */
.cat-label{ display:inline-flex; align-items:center; gap:7px; font-size:12.5px; color:var(--ink-soft);
  margin:14px auto 2px; }
.cat-label .dot{ width:9px; height:9px; border-radius:50%; }
.related{ margin-top:22px; }
.related .rt{ font-family:var(--serif); font-size:15px; color:var(--ink-soft); text-align:center; margin-bottom:12px; }
.related .row{ display:flex; gap:12px; justify-content:center; }
.related .rc{ width:84px; text-align:center; }
.related .rc .thumb{ width:84px; aspect-ratio:5/7; border-radius:10px; overflow:hidden; box-shadow:var(--card-shadow);
  background:var(--surface-2); }
.related .rc .thumb .art{ width:100%; height:100%; object-fit:cover; }
.related .rc .rn{ font-family:var(--serif); font-size:12px; color:var(--ink-soft); margin-top:5px; }

/* card BACK design (deck reverse, before reveal) */
.card-back{ position:relative; width:100%; aspect-ratio:5/7; border-radius:var(--r-lg);
  overflow:hidden; box-shadow:var(--card-shadow); background:var(--surface-2);
  display:grid; place-items:center; }
.card-back .seal{ width:44%; height:44%; opacity:.85; }
.card-back .rim{ position:absolute; inset:12px; border-radius:calc(var(--r-lg) - 8px);
  box-shadow:inset 0 0 0 1.5px var(--line); }
.tap-reveal{ text-align:center; font-size:13px; color:var(--muted); margin-top:14px; }

/* ===================== HOME ===================== */
.hero-hello{ color:var(--ink-soft); font-size:15px; margin-bottom:2px; }
.hero-title{ font-family:var(--serif); font-weight:700; font-size:26px; margin-bottom:16px; }
.home-daily{ margin-bottom:18px; }
.home-actions{ display:grid; grid-template-columns:1fr 1fr; gap:12px; margin:18px 0 8px; }
.action-tile{ background:var(--surface); border-radius:var(--r-md); padding:18px 16px;
  box-shadow:inset 0 0 0 1px var(--line); text-align:right; display:flex; flex-direction:column;
  gap:8px; transition:transform .12s var(--ease); min-height:96px; }
.action-tile:active{ transform:scale(.98); }
.action-tile .ic{ width:26px; height:26px; color:var(--accent); }
.action-tile .t{ font-family:var(--serif); font-weight:700; font-size:16px; }
.action-tile .s{ font-size:12px; color:var(--muted); }
.streak{ display:inline-flex; align-items:center; gap:6px; font-size:13px; color:var(--ink-soft);
  background:var(--surface); padding:6px 12px; border-radius:20px; box-shadow:inset 0 0 0 1px var(--line); }

/* ===================== GALLERY ===================== */
.gallery-tools{ display:flex; gap:10px; margin-bottom:14px; }
.search{ flex:1; display:flex; align-items:center; gap:8px; background:var(--surface);
  border-radius:var(--r-md); padding:10px 14px; box-shadow:inset 0 0 0 1px var(--line); }
.search input{ flex:1; background:none; border:none; outline:none; color:var(--ink); font-size:15px; }
.search svg{ width:18px; height:18px; color:var(--muted); }
.chips{ display:flex; gap:8px; overflow-x:auto; padding-bottom:8px; margin-bottom:12px; scrollbar-width:none; }
.chips::-webkit-scrollbar{ display:none; }
.chip{ white-space:nowrap; padding:7px 14px; border-radius:20px; font-size:13px; color:var(--ink-soft);
  background:var(--surface); box-shadow:inset 0 0 0 1px var(--line); }
.chip.on{ background:var(--accent); color:var(--accent-ink); box-shadow:none; }
.chip.cat-chip{ display:inline-flex; align-items:center; gap:6px; }
.chip.cat-chip .dot{ width:8px; height:8px; border-radius:50%; flex:none; }
.chip.cat-chip.on{ background:var(--cc); color:#fff; }
.chip.cat-chip.on .dot{ background:#fff; }
.grid{ display:grid; grid-template-columns:repeat(2,1fr); gap:14px; }
.tile{ position:relative; border-radius:var(--r-md); overflow:hidden; aspect-ratio:5/7;
  box-shadow:var(--card-shadow); background:var(--surface-2); }
.tile .art{ width:100%; height:100%; object-fit:cover; }
.tile .scrim{ position:absolute; inset:0; background:var(--scrim); }
.tile .kw{ position:absolute; bottom:10px; right:12px; left:12px; color:#f3e6cf;
  font-family:var(--serif); font-size:14px; z-index:2; }
.tile .fav{ position:absolute; top:8px; left:8px; z-index:2; color:#fff; width:32px; height:32px;
  border-radius:50%; display:grid; place-items:center; background:var(--overlay); backdrop-filter:blur(3px); }
.tile .fav svg{ width:18px; height:18px; }
.tile .fav.on{ color:#ff6b7a; }

/* ===================== GAMES ===================== */
.grid-3{ display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.mem-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
.mem{ position:relative; aspect-ratio:5/7; border-radius:10px; overflow:hidden; cursor:pointer;
  box-shadow:var(--card-shadow); background:var(--surface-2); }
.mem .mem-back{ position:absolute; inset:0; display:grid; place-items:center; transition:opacity .2s; }
.mem .mem-back .seal{ width:52%; height:52%; opacity:.7; }
.mem .mem-face{ position:absolute; inset:0; opacity:0; transition:opacity .25s; }
.mem .mem-face .art{ width:100%; height:100%; object-fit:cover; }
.mem.up .mem-face{ opacity:1; }
.mem.up .mem-back{ opacity:0; }
.mem.done{ opacity:.5; }

/* ===================== FLOW / DRAW ===================== */
.flow{ text-align:center; padding-top:6px; }
.flow .prompt{ font-family:var(--serif); font-size:20px; margin:8px 0 18px; }
.field{ width:100%; background:var(--surface); border:none; outline:none; resize:none;
  border-radius:var(--r-md); padding:14px 16px; color:var(--ink); font-size:16px;
  box-shadow:inset 0 0 0 1px var(--line); font-family:var(--sans); }
textarea.field{ min-height:96px; line-height:1.6; }

/* shuffle fan */
.fan{ position:relative; height:280px; margin:10px 0 6px; }
.fan .fc{ position:absolute; top:20px; left:50%; width:120px; aspect-ratio:5/7;
  border-radius:14px; background:var(--surface-2); box-shadow:var(--card-shadow);
  transform-origin:bottom center; transition:transform .5s var(--ease); overflow:hidden; }
.fan .fc .seal{ position:absolute; inset:0; margin:auto; width:50%; height:50%; opacity:.7; }
.fan .fc.pick:active{ transform:translateY(-14px) !important; }

/* reflect prompts */
.reflect{ background:var(--surface); border-radius:var(--r-md); padding:16px;
  box-shadow:inset 0 0 0 1px var(--line); margin:16px 0; text-align:right; }
.reflect .q{ font-family:var(--serif); font-size:16px; color:var(--ink); }
.reflect .q + .q{ margin-top:10px; padding-top:10px; border-top:1px solid var(--line); }

/* ===================== SPREADS ===================== */
.list-card{ display:flex; align-items:center; gap:14px; background:var(--surface);
  border-radius:var(--r-md); padding:16px; box-shadow:inset 0 0 0 1px var(--line); margin-bottom:12px; text-align:right; }
.list-card .n{ font-family:var(--serif); font-weight:700; font-size:17px; }
.list-card .d{ font-size:13px; color:var(--muted); margin-top:2px; }
.list-card .cnt{ margin-inline-start:auto; width:40px; height:40px; border-radius:50%;
  display:grid; place-items:center; background:var(--surface-2); font-family:var(--serif);
  font-weight:700; color:var(--accent); }
.pos-title{ font-family:var(--serif); color:var(--accent); font-size:14px; letter-spacing:.08em; }

/* summary strip of small cards */
.mini-row{ display:flex; gap:10px; justify-content:center; flex-wrap:wrap; margin:14px 0; }
.mini{ width:76px; aspect-ratio:5/7; border-radius:10px; overflow:hidden; box-shadow:var(--card-shadow);
  position:relative; background:var(--surface-2); }
.mini .art{ width:100%; height:100%; object-fit:cover; }

/* ===================== JOURNAL ===================== */
.entry{ background:var(--surface); border-radius:var(--r-md); padding:14px;
  box-shadow:inset 0 0 0 1px var(--line); margin-bottom:12px; display:flex; gap:12px; }
.entry .thumb{ width:56px; flex:none; aspect-ratio:5/7; border-radius:8px; overflow:hidden;
  background:var(--surface-2); }
.entry .thumb .art{ width:100%; height:100%; object-fit:cover; }
.entry .meta{ flex:1; min-width:0; }
.entry .d{ font-size:12px; color:var(--muted); }
.entry .q{ font-family:var(--serif); font-size:15px; margin:2px 0 4px; }
.entry .note{ font-size:14px; color:var(--ink-soft); white-space:pre-wrap; }
.entry .type{ font-size:11px; color:var(--accent); letter-spacing:.08em; }

/* ===================== SETTINGS / ABOUT ===================== */
.section{ background:var(--surface); border-radius:var(--r-md); padding:6px 16px;
  box-shadow:inset 0 0 0 1px var(--line); margin-bottom:16px; }
.row{ display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:14px 0; border-bottom:1px solid var(--line); }
.row:last-child{ border-bottom:none; }
.row .lbl{ font-size:15px; }
.row .hint{ font-size:12px; color:var(--muted); }
.seg{ display:inline-flex; background:var(--surface-2); border-radius:12px; padding:3px; }
.seg button{ padding:7px 12px; border-radius:9px; font-size:13px; color:var(--ink-soft); }
.seg button.on{ background:var(--accent); color:var(--accent-ink); }
.prose{ line-height:1.75; color:var(--ink-soft); }
.prose h3{ font-family:var(--serif); color:var(--ink); font-size:19px; margin:22px 0 8px; }
.prose p{ margin-bottom:12px; }
.prose .lead{ font-family:var(--serif); font-size:19px; color:var(--ink); line-height:1.6; margin-bottom:18px; }
.about-gallery{ display:flex; flex-direction:column; gap:14px; margin:6px 0 22px; }
.about-img{ width:100%; border-radius:var(--r-md); box-shadow:var(--card-shadow); }

/* ===================== INSTALL BAR ===================== */
.installbar{ position:fixed; top:0; left:0; right:0; z-index:80; max-width:var(--maxw); margin:0 auto;
  display:flex; align-items:center; gap:10px;
  padding:10px 14px; padding-top:calc(10px + env(safe-area-inset-top));
  background:var(--accent); color:var(--accent-ink); box-shadow:0 2px 12px rgba(0,0,0,.18); }
.installbar .ib-msg{ flex:1; font-size:13.5px; line-height:1.4; }
.installbar .ib-ic{ display:inline-grid; place-items:center; vertical-align:middle; }
.installbar .ib-ic svg{ width:16px; height:16px; }
.installbar .ib-btn{ background:var(--accent-ink); color:var(--accent); padding:7px 15px; border-radius:12px;
  font-weight:700; font-size:13px; white-space:nowrap; }
.installbar .ib-x{ color:var(--accent-ink); width:30px; height:30px; display:grid; place-items:center; opacity:.9; flex:none; }
.installbar .ib-x svg{ width:18px; height:18px; }
body.has-installbar .app{ padding-top:calc(66px + env(safe-area-inset-top)); }

/* ===================== TABBAR ===================== */
.tabbar{ position:fixed; bottom:0; left:0; right:0; z-index:40;
  display:flex; justify-content:space-around; align-items:center;
  max-width:var(--maxw); margin:0 auto;
  padding:8px 8px calc(8px + env(safe-area-inset-bottom));
  background:color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter:blur(14px); box-shadow:0 -1px 0 var(--line); }
.tabbar a{ display:flex; flex-direction:column; align-items:center; gap:3px;
  font-size:11px; color:var(--muted); padding:4px 10px; border-radius:12px; }
.tabbar a svg{ width:23px; height:23px; }
.tabbar a.on{ color:var(--accent); }

/* ===================== MISC ===================== */
.card-topbar{ display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:10px; }
.card-topbar .ct-right{ display:flex; align-items:center; min-width:0; }
.card-topbar .back-link{ margin-bottom:0; }
.card-topbar .iconbtn{ color:var(--accent); flex:none; }
.back-link{ display:inline-flex; align-items:center; gap:6px; color:var(--ink-soft);
  font-size:14px; margin-bottom:14px; }
.back-link svg{ width:18px; height:18px; }
.empty{ text-align:center; color:var(--muted); padding:50px 20px; }
.empty svg{ width:46px; height:46px; margin:0 auto 12px; opacity:.5; }
.spacer{ height:14px; }
.toast{ position:fixed; bottom:calc(84px + env(safe-area-inset-bottom)); left:50%; transform:translateX(-50%);
  background:var(--ink); color:var(--bg); padding:11px 18px; border-radius:20px; font-size:14px;
  z-index:60; opacity:0; transition:opacity .25s, transform .25s; pointer-events:none; }
.toast.show{ opacity:1; transform:translateX(-50%) translateY(-4px); }

/* fade-in for screens */
.fade-in{ animation:fadein .35s var(--ease); }
@keyframes fadein{ from{ opacity:0; transform:translateY(8px); } to{ opacity:1; transform:none; } }

/* ===================== SPLASH ===================== */
.splash{ position:fixed; inset:0; z-index:100; display:grid; place-items:center;
  background:var(--bg); background-image:var(--bg-grad);
  transition:opacity .55s var(--ease); }
.splash img{ max-width:100%; max-height:100%; width:auto; height:100%; object-fit:contain;
  animation:splashIn .8s var(--ease); }
.splash.hide{ opacity:0; pointer-events:none; }
@keyframes splashIn{ from{ opacity:0; transform:scale(1.02); } to{ opacity:1; transform:none; } }

@media (prefers-reduced-motion: reduce){
  .card{ transition:none; } .fade-in{ animation:none; } .fan .fc{ transition:none; }
  .splash img{ animation:none; }
}
