/* ===== core.css — yaroni studio educational platform ===== */
/* Shared design system for all subject apps                  */

/* ===== Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Varela+Round&family=Assistant:wght@400;600;700;800&display=swap');

/* ===== Design Tokens ===== */
:root {
  --ink: #1f2937;
  --ink-soft: #6b7280;
  --card: #ffffff;
  --muted: #e5e7eb;
  --accent: #3b82f6;
  --accent-2: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 4px 0 rgba(0,0,0,.10), 0 8px 20px rgba(0,0,0,.07);
  --shadow-lift: 0 8px 0 rgba(0,0,0,.12), 0 16px 32px rgba(0,0,0,.11);
}

/* ===== Base ===== */
body {
  font-family: 'Varela Round', 'Assistant', system-ui, -apple-system, sans-serif;
  color: var(--ink);
}

/* ===== App Shell — 480px centered on desktop, full-width on mobile ===== */
.app-shell {
  max-width: 480px;
  width: 100%;
  margin-inline: auto;
}

/* ===== Icon Bubble — emoji wrapped in a colored circle ===== */
.icon-bubble {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1rem;
  flex-shrink: 0;
  margin: 0 auto;
}
.icon-bubble-sm {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* ===== Duolingo-style Primary Button ===== */
.btn-duo {
  display: block;
  width: 100%;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 800;
  font-size: 1.1rem;
  text-align: center;
  cursor: pointer;
  border: none;
  letter-spacing: .01em;
  transition: transform .12s, box-shadow .12s;
  box-shadow: 0 4px 0 rgba(0,0,0,.20);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn-duo:active           { transform: translateY(3px); }
.btn-duo:disabled,
.btn-duo[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-duo-green  { background: #22c55e; color: #fff; box-shadow: 0 4px 0 #15803d; }
.btn-duo-blue   { background: #3b82f6; color: #fff; box-shadow: 0 4px 0 #1d4ed8; }
.btn-duo-purple { background: #8b5cf6; color: #fff; box-shadow: 0 4px 0 #6d28d9; }
.btn-duo-gray   { background: #e5e7eb; color: #374151; box-shadow: 0 4px 0 #9ca3af; }
.btn-duo-green:active  { box-shadow: 0 1px 0 #15803d; }
.btn-duo-blue:active   { box-shadow: 0 1px 0 #1d4ed8; }
.btn-duo-purple:active { box-shadow: 0 1px 0 #6d28d9; }
.btn-duo-gray:active   { box-shadow: 0 1px 0 #9ca3af; }

/* ===== Accessibility ===== */
.no-focus-outline:focus { outline: none !important; box-shadow: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ===== Direction helpers ===== */
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.tabular-nums { font-variant-numeric: tabular-nums; }

/* ===== Typography ===== */
.subhead {
  font-weight: 700;
  font-size: clamp(1.1rem, .95rem + .8vw, 1.375rem);
  line-height: 1.3;
  color: #374151;
}

/* ===== Cards & Selectable Items ===== */
.choice-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  background: #fff;
  border: 2px solid transparent;
  border-radius: 1.25rem;
  padding: 1.15rem;
  box-shadow: var(--shadow);
  transition: .18s;
  cursor: pointer;
  outline: none;
  user-select: none;
  min-height: 92px;
  text-decoration: none;
  color: inherit;
}
.choice-card:hover  { transform: translateY(-2px); }
.choice-card:active { transform: scale(.98); }
.choice-card.selected { border-color: #2563eb; box-shadow: 0 12px 30px rgba(0,0,0,.18); }
.choice-card .emoji { font-size: 2rem; }

.chip {
  min-width: 68px;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #e5e7eb;
  background: white;
  border-radius: 1rem;
  padding: .3rem .85rem;
  font-weight: 700;
  font-size: 1.175rem;
  cursor: pointer;
  transition: .16s;
}
.chip:hover    { transform: translateY(-2px); }
.chip.selected { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.20); }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }

/* ===== Answer Items ===== */
.answer-item {
  position: relative;
  transition: transform .14s, box-shadow .14s, border-color .14s;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: rgba(255,255,255,.98);
  border-radius: 1rem;
  border: 2px solid transparent;
  outline: none;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.answer-item:active   { transform: scale(.98); }
.answer-item.selected { border-color: #2563eb; box-shadow: 0 12px 30px rgba(0,0,0,.18); }

/* Text inside answer items (used by madaonchik for RTL/LTR detection) */
.answer-text { width: 100%; text-align: center; font-size: 1.25rem; font-weight: 600; line-height: 1.5; word-break: break-word; hyphens: auto; }
.answer-text.ltr { direction: ltr; unicode-bidi: embed; }
.answer-text.rtl { direction: rtl; unicode-bidi: embed; }

/* ===== Buttons ===== */
.confirm-button { transition: all .25s; }
.confirm-button[disabled] { opacity: .5; cursor: not-allowed; }
.btn-disabled { opacity: .5; cursor: not-allowed; }

/* ===== Links / CTAs ===== */
.link-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  margin: .5rem auto 1rem;
  font-weight: 800;
  font-size: calc(1rem + 1px);
  color: #111827;
  text-decoration: underline;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: .25rem .5rem;
  border-radius: .5rem;
}
.link-cta:focus { outline: 2px solid #93c5fd; outline-offset: 2px; }

/* ===== Floating Controls ===== */
#floatingControls {
  position: fixed;
  left: 16px;
  top: 16px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Push controls below the context bar when it's visible */
body.has-ctx-bar #floatingControls {
  top: 62px;
}
#audioToggle,
#profileBtn {
  padding: .5rem .7rem;
  border-radius: 9999px;
  background: rgba(255,255,255,.95);
  border: 1px solid #e5e7eb;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  font-size: 20px;
  cursor: pointer;
}
#audioToggle:focus,
#profileBtn:focus { outline: 2px solid #93c5fd; outline-offset: 2px; }

/* ===== Site Signature (footer) ===== */
.site-signature {
  text-align: center;
  color: #6b7280;
  font-size: .925rem;
  line-height: 1.6;
  margin: 1.5rem auto;
}
@media (min-width: 640px) { .site-signature { font-size: 1rem; margin: 2rem auto; } }
.site-signature a       { color: #4b5563; text-decoration: underline; }
.site-signature a:hover { color: #111827; }

/* ===== Progress bar (shared structure) ===== */
#progressBar { transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* ===== Form error shake ===== */
@keyframes form-shake {
  0%,100%{ transform: translateX(0); }
  20%    { transform: translateX(-6px); }
  40%    { transform: translateX( 6px); }
  60%    { transform: translateX(-4px); }
  80%    { transform: translateX( 4px); }
}
.shake { animation: form-shake .4s ease-in-out; }

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===== Context Bar ===== */
#contextBar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: .2rem;
  padding: .4rem .75rem;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 2px solid #e5e7eb;
  box-shadow: 0 2px 10px rgba(0,0,0,.07);
  font-size: .875rem;
  font-weight: 700;
  direction: rtl;
}
#contextBar.ctx-hidden { display: none !important; }
body.has-ctx-bar { padding-top: 52px; }

.ctx-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .35rem .7rem;
  border-radius: 999px;
  color: #374151;
  text-decoration: none;
  transition: background .15s;
  white-space: nowrap;
  font-size: .875rem;
}
.ctx-btn:hover { background: #f3f4f6; }
.ctx-btn:focus { outline: 2px solid #93c5fd; outline-offset: 2px; }
.ctx-btn.ctx-btn-active {
  color: #4f46e5;
  background: #eef2ff;
  font-weight: 800;
}
.ctx-sep { color: #d1d5db; padding: 0 .1rem; font-weight: 400; }

/* ===== Mobile: prevent input zoom on iOS ===== */
@media (max-width: 767px) {
  input[type="text"],
  input[type="number"],
  select,
  textarea { font-size: 16px !important; }

  .answer-item { min-height: 64px; }

  .confirm-button,
  #confirmButton {
    padding-bottom: max(.75rem, calc(.75rem + env(safe-area-inset-bottom, 0px)));
  }
}
