/* ── Shana Tova 5787 ───────────────────────────────────────────
   Three colours, two faces, hairlines instead of shadows.

   paper  #FFFFFF   ground
   ink    #111111   type, rules, and the תכלה stamp
   accent green = right/תחל, no red = left/תכלה

   Display: Frank Ruhl Libre 900 · UI/body: Heebo
   ────────────────────────────────────────────────────────────── */

:root {
  --paper:  #FFFFFF;
  --ink:    #111111;
  --accent: #1FA36A;   /* right · תחל · green */
  --accent-text: #178A5A;
  --no: #D63A4A;       /* left · תכלה · red */

  /* the only derived values: flat tints of ink, no new hues */
  --rule:   rgba(17, 17, 17, .22);
  --rule-2: rgba(17, 17, 17, .10);
  --dim:    rgba(17, 17, 17, .55);
  --faint:  rgba(17, 17, 17, .04);
  --scrim:  rgba(17, 17, 17, .86);

  --display: "Frank Ruhl Libre", "Times New Roman", Georgia, serif;
  --body: "Heebo", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  --pad: clamp(1.125rem, 5vw, 2rem);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --r: 2px;
  --r-card: 10px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:  #0D0D0D;
    --ink:    #F4F4F4;
    --accent: #3DD68C;
    --accent-text: #3DD68C;
    --no: #FF5A6A;
    --rule:   rgba(244, 244, 244, .26);
    --rule-2: rgba(244, 244, 244, .12);
    --dim:    rgba(244, 244, 244, .58);
    --faint:  rgba(244, 244, 244, .06);
    --scrim:  rgba(13, 13, 13, .86);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; overflow-x: hidden; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;

  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: var(--safe-t) 0 var(--safe-b);
}

::selection { background: var(--accent); color: #fff; }

:where(a, button):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* Physical directions stay physical in RTL: left is always תכלה. */
.dirs, .progress-row, .controls, .recap, .card, .end-actions { direction: ltr; }
.dir-text, .edge-label, .counter, .recap-cell, .card-body, .stamp { direction: inherit; }
html[dir="rtl"] .dir-text,
html[dir="rtl"] .edge-label,
html[dir="rtl"] .counter,
html[dir="rtl"] .recap-cell,
html[dir="rtl"] .card-body,
html[dir="rtl"] .stamp { direction: rtl; }

/* ── Chrome ─────────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: .7rem var(--pad);
  border-bottom: 1px solid var(--rule);
  direction: ltr;            /* same layout in every language */
}
.brand { direction: inherit; }

.brand {
  font-family: var(--body);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
html[dir="rtl"] .brand { letter-spacing: 0; font-size: .85rem; }

.langs { display: flex; gap: .25rem; direction: ltr; }

.lang {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--dim);
  font: 500 .72rem/1 var(--body);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .45rem .55rem;
  cursor: pointer;
  border-radius: var(--r);
}
.lang:hover { color: var(--ink); }
.lang[aria-current="true"] {
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .35em;
  text-decoration-thickness: 1.5px;
}

.footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: .7rem var(--pad);
  border-top: 1px solid var(--rule);
  font-size: .72rem;
  color: var(--dim);
  direction: ltr;            /* same layout in every language */
}
.credits-link {
  color: var(--dim);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1px;
  white-space: nowrap;
}
.credits-link:hover { color: var(--ink); border-color: currentColor; }

/* ── Screens ────────────────────────────────────────────────── */

main {
  min-height: 0;
  display: grid;
}
.screen { display: none; min-height: 0; }
.screen.is-active { display: grid; }

/* ── Intro ──────────────────────────────────────────────────── */

.screen--intro { align-content: center; justify-items: stretch; }

.intro-inner {
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 6vw, 3rem) var(--pad);
}

.display {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.75rem, 13vw, 5.25rem);
  line-height: .92;
  letter-spacing: -.02em;
  margin: 0;
}
html[dir="rtl"] .display { letter-spacing: 0; line-height: 1.02; }
.display { position: relative; padding-bottom: .7em; contain: inline-size; } /* title never widens its ancestors */
.display > span:first-child { position: relative; z-index: 1; white-space: nowrap; display: inline-block; }
/* the year hangs off the greeting as a ghost: outlined, overlapping the baseline */
.display-year {
  position: absolute;
  inset-inline-start: -.12em;   /* nudged past the greeting's start edge */
  bottom: -.08em;
  z-index: 0;
  font-weight: 900;
  font-size: 1.55em;            /* wider than the greeting's last line, juts out both sides */
  line-height: 1;
  letter-spacing: 0;
  color: rgba(17,17,17,.12);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}
@media (prefers-color-scheme: dark) {
  :root .display-year { color: rgba(244,244,244,.30); }
}

.subtitle {
  margin: .85rem 0 0;
  font-size: 1rem;
  color: var(--dim);
  max-width: 32ch;
}

.dirs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: clamp(1.75rem, 6vw, 2.5rem) 0 0;
}
.dir {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
}
.dir--right {
  justify-content: flex-end;
  text-align: right;
  color: var(--accent-text);
}

/* same round icon as the deck controls, so the intro previews them */
.dir-icon {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid currentColor;
  display: grid; place-items: center;
}
.dir-icon svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.dir--right .dir-icon { color: var(--accent); }
.dir-text { display: grid; gap: .15rem; min-width: 0; justify-items: start; }
.dir--right .dir-text { justify-items: end; }

.dir-label {
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
}
.dir--left { color: var(--no); }
.dir--left .dir-label, .dir--right .dir-label { color: inherit; opacity: .75; }
html[dir="rtl"] .dir-label { letter-spacing: .02em; font-size: .74rem; }

.dir-phrase {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(.95rem, 3.6vw, 1.15rem);
  line-height: 1.25;
}

.intro-text {
  margin: 1.5rem 0 0;
  max-width: 44ch;
  font-size: .92rem;
  color: var(--dim);
}

/* ── Buttons ────────────────────────────────────────────────── */

.btn {
  appearance: none;
  display: inline-block;
  border: 1px solid var(--ink);
  border-radius: var(--r);
  background: var(--ink);
  color: var(--paper);
  font: 700 .78rem/1 var(--body);
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 1.05rem 1.6rem;
  cursor: pointer;
  transition: background .12s linear, color .12s linear;
}
html[dir="rtl"] .btn { letter-spacing: .02em; font-size: .95rem; }

.btn--primary { margin-top: 1.75rem; }
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .35; cursor: default; }

.btn--ghost {
  background: transparent;
  color: var(--ink);
  margin-top: 0;
}
.btn--ghost:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ── Deck ───────────────────────────────────────────────────── */

.screen--deck {
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 clamp(.75rem, 3.5vw, 2rem);
}

.deck-head { padding: .7rem 0 .45rem; }

.progress-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem;
  margin-bottom: .4rem;
}

.edge-label {
  font-size: .58rem;
  opacity: .8;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.edge-label--left  { text-align: left; color: var(--no); }
.edge-label--right { text-align: right; color: var(--accent-text); }
html[dir="rtl"] .edge-label { letter-spacing: .02em; font-size: .7rem; }

.counter {
  flex: none;
  color: var(--dim);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
html[dir="rtl"] .counter { letter-spacing: .02em; font-size: .78rem; }

.progressbar {
  position: relative;
  height: 2px;
  background: transparent;   /* no hairline; only the green fill shows progress */
  direction: ltr;
}
.progressbar span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--accent);
  transition: width .28s cubic-bezier(.2,.7,.3,1);
}

.deck {
  min-height: 0;
  min-width: 0;
  padding: .5rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The stack is the card's shape: a tall Tinder rectangle that fills the
   height it is given, then shrinks if that would make it too wide. */
.stack {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  max-height: 100%;
}

/* ── Card ───────────────────────────────────────────────────── */

.card {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--paper);
  border: 0;
  border-radius: var(--r-card);
  transform-origin: 50% 100%;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.card--top { cursor: grab; }
.card--top.is-dragging, .card.is-animating, .card.is-gone { will-change: transform; }
.card--top.is-dragging { cursor: grabbing; }
.card.is-animating { transition: transform .34s cubic-bezier(.2,.7,.3,1); }
.card.is-gone { transition: transform .4s cubic-bezier(.4,0,.7,.2); }

/* The photo is the card: edge to edge, full bleed. */
.card-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 32%;
  pointer-events: none;
}

/* The text block sits at the bottom-left of the photo — bottom-right in RTL. */
.card-body {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: .7rem;
  display: flex;
  pointer-events: none;
}

.card-info {
  max-width: 100%;
  padding: .6rem .75rem .65rem;
  background: rgba(0, 0, 0, .65);
  border-radius: 6px;
  color: #fff;
}

.card-name {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(1.2rem, 5.4vw, 1.55rem);
  line-height: 1.14;
  letter-spacing: -.01em;
  contain: inline-size;         /* never widens the info box */
}
.card-name-text { white-space: nowrap; display: inline-block; max-width: 100%; }
.card-name-text.is-wrapped { white-space: normal; text-wrap: balance; }
html[dir="rtl"] .card-name { letter-spacing: 0; line-height: 1.26; }

.card-day {
  margin: .1rem 0 0;
  font-family: var(--body);
  font-weight: 400;
  font-size: .95rem;
  letter-spacing: 0;
  white-space: nowrap;
  opacity: .92;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: .3rem;
  margin: .3rem 0 0;
  font-size: .72rem;
  font-weight: 500;
  line-height: 1.3;
  opacity: .92;
}
html[dir="rtl"] .card-meta { font-size: .78rem; }

.card-meta-icon {
  flex: none;
  width: 13px; height: 13px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.card-blurb {
  margin: .3rem 0 0;
  font-size: .8rem;
  line-height: 1.45;
  opacity: .78;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Stamps ─────────────────────────────────────────────────── */

.stamp {
  position: absolute;
  top: 1.1rem;
  max-width: calc(100% - 2.2rem);
  padding: .45rem .7rem;
  border: 2px solid #fff;
  border-radius: var(--r);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  display: grid;
  gap: .1rem;
}
.stamp--left  { left: 1.1rem;  background: var(--no); transform: rotate(-12deg); }
.stamp--right { right: 1.1rem; background: var(--accent); transform: rotate(12deg); }

.stamp-main {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(.95rem, 4.2vw, 1.2rem);
  line-height: 1.15;
  white-space: nowrap;
}
.stamp-sub {
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .8;
}
html[dir="rtl"] .stamp-sub { letter-spacing: 0; font-size: .68rem; text-transform: none; }

/* ── Controls ───────────────────────────────────────────────── */

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: .9rem 0 1.1rem;
}

/* Three identical circles: undo · nope · like. */
.ctl {
  appearance: none;
  width: 3.5rem;
  height: 3.5rem;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: background .12s linear, color .12s linear, border-color .12s linear;
}
.ctl svg {
  width: 24px; height: 24px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.ctl--undo { color: var(--dim); }
.ctl--yes  { color: var(--accent); }
.ctl--no   { color: var(--no); }

.ctl:hover, .ctl:active {
  background: currentColor;
  border-color: currentColor;
}
.ctl:hover svg, .ctl:active svg { stroke: var(--paper); }
.ctl--yes:hover svg, .ctl--yes:active svg { stroke: #fff; }

.ctl:disabled { opacity: .3; cursor: default; }
.ctl:disabled:hover { background: var(--paper); border-color: var(--rule); }
.ctl:disabled:hover svg { stroke: currentColor; }

@media (min-width: 480px) {
  .ctl { width: 3.75rem; height: 3.75rem; }
}

/* ── End ────────────────────────────────────────────────────── */

.screen--end { align-content: center; }

.end-inner {
  width: 100%;
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 6vw, 3rem) var(--pad);
}

.display--end { font-size: clamp(2.25rem, 10vw, 4.25rem); }

.end-body {
  margin: 1rem 0 0;
  max-width: 44ch;
  font-size: .95rem;
  color: var(--dim);
}

.recap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: clamp(1.75rem, 6vw, 2.5rem) 0 0;
}
.recap-cell { padding: 1rem 0; min-width: 0; }
.recap-cell--left  { text-align: left; color: var(--no); }
.recap-cell--right {
  text-align: right;
  color: var(--accent);
}

.recap-num {
  display: block;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2.25rem, 9vw, 3rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.recap-lbl {
  display: block;
  margin-top: .4rem;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
}
.recap-cell--right .recap-lbl { color: inherit; opacity: .75; }
html[dir="rtl"] .recap-lbl { letter-spacing: .02em; font-size: .74rem; }

.agree {
  margin: 1.1rem 0 0;
  font-size: .85rem;
  color: var(--dim);
}

.end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: 1.75rem;
}
.end-actions .btn { margin-top: 0; }

/* ── Toast ──────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + var(--safe-b));
  transform: translateX(-50%) translateY(.4rem);
  padding: .6rem 1rem;
  background: var(--scrim);
  color: var(--paper);
  border-radius: var(--r);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s linear, transform .16s linear;
  z-index: 50;
}
html[dir="rtl"] .toast { letter-spacing: 0; text-transform: none; font-size: .85rem; }
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Wide ───────────────────────────────────────────────────── */

@media (min-width: 900px) {
  .screen--deck { max-width: 27rem; }
  .deck { padding: 1rem 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
