/* ============================================================
   Hebrew Today — Shared Theme
   Tokens, base type, topbar, container, buttons, forms, flashes,
   page footer, animations, reduced-motion safety net.
   This file is loaded on every page using the new design system.
   Page-specific styles (lesson cards, hero, legend, etc.) live in
   lessons.css / lesson.css.
   ============================================================ */

:root {
  /* Backdrop & ink */
  --bg:           #fff5e6;     /* peach cream */
  --bg-soft:      #ffeed3;
  --card:         #ffffff;
  --ink:          #2b2247;     /* deep blue-purple */
  --ink-soft:     #5a5375;
  --ink-mute:     #8a83a0;
  --hair:         #ece4d4;
  --hair-strong:  #d8cfbb;

  /* Vibrant accent palette (cycle 5 across cards/tiles) */
  --teal:         #2dbab1;
  --teal-shade:   #1c8a82;
  --coral:        #ff7c5a;
  --coral-shade:  #d94f30;
  --gold:         #f4b13f;
  --gold-shade:   #c2871a;
  --sky:          #5cb6e6;
  --sky-shade:    #2d8bbe;
  --grape:        #a280df;
  --grape-shade:  #6f4dbb;

  /* State colors */
  --done:         #4ec77f;
  --done-shade:   #2d9c5b;
  --done-glow:    #b6f0cd;
  --locked:       #d6d0e0;
  --locked-shade: #a9a3b6;
  --locked-fg:    #8a83a0;
  --danger:       #e85a5a;
  --danger-shade: #b13838;
  --info:         var(--sky);
  --info-shade:   var(--sky-shade);

  /* Star / accent */
  --star:         #ffc94d;

  /* Type */
  /* 'AppHebrew' is a virtual font (declared via @font-face below) that maps
     all Hebrew code points to local Arial. Prepending it to --display and
     --body means Hebrew anywhere in the app — even inside Bricolage/Nunito
     headings or mixed-language text — renders in Arial to match main.
     English/Latin code points fall through to Bricolage / Nunito as before. */
  --display: "AppHebrew", "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --body:    "AppHebrew", "Nunito", "Avenir Next", system-ui, sans-serif;
  --hebrew:  Arial, Helvetica, sans-serif;

  /* Motion */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Virtual Hebrew font: routes Hebrew Unicode (U+0590–05FF + Hebrew
   presentation forms U+FB1D–FB4F) through local Arial. Referenced by
   --display and --body above so all Hebrew renders in Arial regardless
   of the surrounding element's font. */
@font-face {
  font-family: "AppHebrew";
  src: local("Arial"), local("Helvetica");
  unicode-range: U+0590-05FF, U+FB1D-FB4F;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: var(--body);
  font-weight: 600;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* ============================================================
   BACKGROUND ATMOSPHERE
   ============================================================ */

.bg-shapes {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-shape {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.55;
}

.bg-shape--1 {
  width: 280px; height: 280px;
  top: -80px; left: -90px;
  background: radial-gradient(circle, rgba(255, 124, 90, 0.25), rgba(255, 124, 90, 0) 70%);
}

.bg-shape--2 {
  width: 360px; height: 360px;
  top: 8%; right: -120px;
  background: radial-gradient(circle, rgba(45, 186, 177, 0.22), rgba(45, 186, 177, 0) 70%);
}

.bg-shape--3 {
  width: 240px; height: 240px;
  bottom: 12%; left: -60px;
  background: radial-gradient(circle, rgba(244, 177, 63, 0.22), rgba(244, 177, 63, 0) 70%);
}

.bg-shape--4 {
  width: 200px; height: 200px;
  bottom: -50px; right: 12%;
  background: radial-gradient(circle, rgba(92, 182, 230, 0.22), rgba(92, 182, 230, 0) 70%);
}

main, header, footer { position: relative; z-index: 1; }

/* ============================================================
   TOP BAR
   ============================================================ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: rgba(255, 245, 230, 0.85);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--hair);
  position: sticky;
  top: 0;
  z-index: 5;
}

@media (min-width: 768px) {
  .topbar { padding: 1rem 2.25rem; }
}

@media (min-width: 1024px) {
  .topbar { padding: 1.1rem 3rem; }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
}

.brand img {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

@media (min-width: 768px) { .brand img { height: 38px; } }

.brand-wordmark {
  display: inline-flex;
  flex-direction: column;
  line-height: 1;
  white-space: nowrap;
}

.brand-wordmark-name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.brand-wordmark-tag {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--coral);
  margin-top: 0.2rem;
}

@media (min-width: 768px) {
  .brand-wordmark-name { font-size: 1.2rem; }
  .brand-wordmark-tag  { font-size: 0.66rem; }
}

@media (max-width: 419px) {
  .brand-wordmark { display: none; }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Mobile: hamburger replaces the pill row entirely */
@media (max-width: 767px) {
  .topbar-actions { display: none; }
}

.hi-user {
  display: none;
  align-items: center;
  gap: 0.4rem;
  padding-right: 0.5rem;
  font-family: var(--body);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

@media (min-width: 768px) { .hi-user { display: inline-flex; } }

.hi-wave {
  display: inline-block;
  font-size: 1.1rem;
  animation: wave 2.5s ease-in-out infinite;
  transform-origin: 70% 70%;
}

.hi-text strong {
  font-family: var(--display);
  font-weight: 700;
  color: var(--ink);
}

@keyframes wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(14deg); }
  20% { transform: rotate(-10deg); }
  30% { transform: rotate(14deg); }
  40% { transform: rotate(-6deg); }
  50% { transform: rotate(10deg); }
}

/* ============================================================
   PILL LINKS — secondary nav buttons
   ============================================================ */

.pill-link {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 2px solid var(--hair-strong);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  white-space: nowrap;
  cursor: pointer;
}

.pill-link:hover {
  background: #fff;
  border-color: var(--ink);
  transform: translateY(-1px);
}

.pill-link--admin {
  background: var(--coral);
  color: #fff;
  border-color: var(--coral-shade);
}

.pill-link--admin:hover {
  background: var(--coral-shade);
  color: #fff;
  border-color: var(--coral-shade);
}

/* ============================================================
   CONTAINER
   ============================================================ */

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

@media (min-width: 768px) { .container { padding: 2rem 1.75rem 3rem; } }
@media (min-width: 1024px) { .container { padding: 2.5rem 2.5rem 4rem; } }

.container--narrow { max-width: 720px; }
.container--reading { max-width: 680px; }

/* ============================================================
   BUTTONS — chunky 3D
   The :active translation must match the shadow offset so the
   button visually "sits down" instead of floating.
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.3rem;
  background: var(--coral);
  color: #fff;
  text-decoration: none;
  border: none;
  border-radius: 999px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.005em;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
  touch-action: manipulation;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 0 var(--ink); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }

.btn--block { display: flex; width: 100%; }
.btn--lg { font-size: 1.05rem; padding: 0.95rem 1.6rem; box-shadow: 0 6px 0 var(--ink); }
.btn--lg:hover { box-shadow: 0 8px 0 var(--ink); }
.btn--lg:active { box-shadow: 0 1px 0 var(--ink); }

.btn--gold { background: var(--gold); color: var(--ink); box-shadow: 0 5px 0 var(--ink); }
.btn--gold:hover { box-shadow: 0 6px 0 var(--ink); }
.btn--gold:active { box-shadow: 0 1px 0 var(--ink); }

.btn--teal { background: var(--teal); color: #fff; box-shadow: 0 5px 0 var(--ink); }
.btn--teal:hover { box-shadow: 0 6px 0 var(--ink); }
.btn--teal:active { box-shadow: 0 1px 0 var(--ink); }

.btn--sky { background: var(--sky); color: #fff; box-shadow: 0 5px 0 var(--ink); }
.btn--sky:hover { box-shadow: 0 6px 0 var(--ink); }
.btn--sky:active { box-shadow: 0 1px 0 var(--ink); }

.btn--ghost {
  background: #fff;
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 0 5px 0 var(--ink);
}
.btn--ghost:hover { box-shadow: 0 6px 0 var(--ink); background: var(--bg-soft); }
.btn--ghost:active { box-shadow: 0 1px 0 var(--ink); }

.btn--danger { background: var(--danger); color: #fff; box-shadow: 0 5px 0 var(--ink); }
.btn--danger:hover { box-shadow: 0 6px 0 var(--ink); }
.btn--danger:active { box-shadow: 0 1px 0 var(--ink); }

.btn-admin { background: #fff; color: var(--coral); border: 2px solid var(--coral-shade); }

.btn[disabled],
.btn[aria-disabled="true"] {
  background: var(--locked);
  color: var(--locked-fg);
  box-shadow: 0 3px 0 var(--locked-shade);
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================================
   FORM CONTROLS
   Used by every form across the app. Don't add page-specific
   form CSS unless you genuinely need it.
   ============================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
  text-align: left;
}

.form-group label,
.form-label {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="search"],
.form-group input:not([type]),
.form-group textarea,
.form-group select,
.form-input {
  font-family: var(--body);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--hair-strong);
  border-radius: 14px;
  padding: 0.75rem 0.95rem;
  width: 100%;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  -webkit-appearance: none;
  appearance: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.form-input:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(255, 124, 90, 0.18);
}

.form-group input:focus-visible,
.form-input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.form-hint {
  font-family: var(--body);
  font-size: 0.8rem;
  color: var(--ink-mute);
  margin-top: 0.1rem;
}

/* Numeric verification code input — big tracked digits */
.code-input,
.magic-code-input,
.auth-code-input {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 0.4em;
  text-align: center;
  text-indent: 0.4em; /* re-centre after letter-spacing */
  padding: 0.85rem 0.5rem !important;
}

/* ============================================================
   FLASH MESSAGES
   Replaces /static/flash.css for new-system pages. Kept-class
   compatible with .flash.error / .flash.info / .flash.success
   so existing markup keeps working unchanged.
   ============================================================ */

.flash {
  font-family: var(--body);
  font-weight: 700;
  border-radius: 16px;
  padding: 0.85rem 1.1rem;
  margin: 0 0 1rem;
  border: 2px solid;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  line-height: 1.4;
}

.flash::before {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  font-weight: 900;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.flash h4 { margin: 0 0 0.25rem; font-family: var(--display); font-weight: 800; font-size: 1rem; }
.flash p { margin: 0; }

.flash.error,
.flash--error {
  background: rgba(232, 90, 90, 0.10);
  color: var(--danger-shade);
  border-color: var(--danger);
}
.flash.error::before,
.flash--error::before {
  content: "!";
  background: var(--danger);
  color: #fff;
}

.flash.success,
.flash--success {
  background: rgba(78, 199, 127, 0.14);
  color: var(--done-shade);
  border-color: var(--done);
}
.flash.success::before,
.flash--success::before {
  content: "\2713";
  background: var(--done);
  color: #fff;
}

.flash.info,
.flash--info {
  background: rgba(92, 182, 230, 0.14);
  color: var(--sky-shade);
  border-color: var(--sky);
}
.flash.info::before,
.flash--info::before {
  content: "i";
  background: var(--sky);
  color: #fff;
  font-style: normal;
}

.flash.warning,
.flash--warning {
  background: rgba(244, 177, 63, 0.16);
  color: var(--gold-shade);
  border-color: var(--gold);
}
.flash.warning::before,
.flash--warning::before {
  content: "!";
  background: var(--gold);
  color: var(--ink);
}

.flash.hidden { display: none; }

/* ============================================================
   AUTH CARD
   The centered single-card layout used by login, signup,
   forgot/reset password, MFA flows, email verification, etc.
   ============================================================ */

.auth-card {
  max-width: 460px;
  margin: 2.5rem auto 4rem;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 28px;
  box-shadow: 0 6px 0 var(--ink);
  padding: 2rem 1.75rem 2.25rem;
  position: relative;
  animation: popIn 0.6s 0.05s both var(--spring);
}

@media (min-width: 640px) {
  .auth-card { padding: 2.5rem 2.25rem 2.75rem; }
}

.auth-card::before {
  content: "";
  position: absolute;
  top: -14px; left: 50%;
  width: 56px; height: 28px;
  background: var(--gold);
  border: 3px solid var(--ink);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  transform: translateX(-50%);
}

.auth-card-eyebrow {
  display: inline-block;
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--coral);
  background: var(--bg-soft);
  border: 2px solid var(--coral);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  margin: 0 auto 0.85rem;
}

.auth-card-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.5rem, 4vw, 1.95rem);
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0 0 0.5rem;
  text-align: center;
  line-height: 1.1;
}

.auth-card-tagline {
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-soft);
  text-align: center;
  margin: 0 0 1.6rem;
  line-height: 1.45;
}

.auth-card-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-links {
  margin-top: 1.2rem;
  text-align: center;
  font-family: var(--body);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.auth-links a {
  color: var(--coral-shade);
  text-decoration: none;
  font-weight: 800;
}

.auth-links a:hover { text-decoration: underline; }

/* For multi-step flows (email → code) */
.auth-step + .auth-step { margin-top: 0; }
.auth-step.hidden,
.magic-link-hidden { display: none; }
.magic-link-visible { display: block; }

.code-instruction,
.code-hint {
  font-family: var(--body);
  text-align: center;
  margin: 0 0 0.9rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

.code-instruction strong {
  color: var(--ink);
  font-weight: 800;
  font-family: var(--display);
}

.code-hint {
  font-size: 0.82rem;
  color: var(--ink-mute);
  margin-bottom: 1.4rem;
}

/* Stack of secondary buttons under primary */
.auth-button-stack {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-top: 0.8rem;
}

/* ============================================================
   READING CARD — long-form text in a single card
   Used by: /credits, blog article, error, pricing-success, etc.
   ============================================================ */

.reading-card,
.credits-container {
  max-width: 760px;
  margin: 2.5rem auto;
  padding: 2rem 1.75rem;
  background: #fff;
  border: 2px solid var(--hair-strong);
  border-radius: 24px;
  box-shadow: 0 6px 0 var(--hair-strong);
  font-family: var(--body);
  position: relative;
  z-index: 1;
}

@media (min-width: 768px) {
  .reading-card,
  .credits-container { padding: 2.5rem 2.5rem; }
}

.reading-card h1,
.reading-card h2,
.credits-container h2 {
  font-family: var(--display);
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 0.85rem;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

.reading-card p,
.credits-container p {
  line-height: 1.55;
  margin-bottom: 0.6rem;
  color: var(--ink-soft);
  font-size: 1rem;
  font-weight: 600;
}

.reading-card .footer-nav,
.credits-container .footer-nav {
  margin-top: 2rem;
  padding-top: 1.2rem;
  border-top: 2px solid var(--hair);
}

.reading-card .footer-nav a,
.credits-container .footer-nav a {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
  text-decoration: none;
  background: var(--bg-soft);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 2px solid var(--hair-strong);
  box-shadow: 0 3px 0 var(--hair-strong);
  transition: transform 0.18s ease;
  display: inline-block;
}

.reading-card .footer-nav a:hover,
.credits-container .footer-nav a:hover { transform: translateY(-1px); }

/* ============================================================
   PAGE FOOTER
   ============================================================ */

.page-footer {
  text-align: center;
  padding: 2.5rem 1.5rem 2rem;
  position: relative;
  z-index: 1;
}

.footer-link {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-decoration: none;
  background: #fff;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 2px solid var(--hair-strong);
  box-shadow: 0 3px 0 var(--hair-strong);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  display: inline-block;
}

.footer-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--hair-strong);
  color: var(--ink);
}

.footer-sep {
  display: inline-block;
  margin: 0 0.6rem;
  color: var(--ink-mute);
  font-weight: 700;
}

/* ============================================================
   GLOBAL ANIMATIONS
   Page-specific keyframes (starPop, herePop, hereWiggle, etc.)
   live with the components that use them in lessons.css.
   ============================================================ */

@keyframes popIn {
  from { opacity: 0; transform: translateY(10px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cardPop {
  from { opacity: 0; transform: translateY(20px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes twinkle {
  0%, 100% { transform: scale(1) rotate(0); opacity: 0.85; }
  50%      { transform: scale(1.18) rotate(15deg); opacity: 1; }
}

/* Reduced motion — kill every animation/transition */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
