/* Sentence Builder | AmicaEd: styles */
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
/* ------------------------------------------------------------------
   AmicaEd visual grammar (taken from the logo)
   Navy  = structure: text, outlines, main actions, tiles you can move
   Teal  = right / progress: ticks, correct words, completed typing
   Gold  = attention: drop target, "try again", the full stop
   ------------------------------------------------------------------ */
:root {
  --navy: #08366C;
  --navy-soft: #3E5878;
  --navy-tint: #E8EFF8;
  --navy-shadow: #B9C9DD;
  --teal: #059FAA;
  --teal-deep: #04727B;
  --teal-tint: #DDF3F5;
  --gold: #FBB525;
  --gold-deep: #C27E00;
  --gold-tint: #FFF1CC;
  --paper: #F2F6FB;
  --white: #FFFFFF;
  --line: #C9D5E4;
  --radius: 14px;
  --radius-lg: 22px;

  --tile-fs: 1.6rem;
  --slot-w: 108px;
  --slot-h: 68px;
}

body[data-level="prep"] { --tile-fs: 2.2rem;  --slot-w: 130px; --slot-h: 80px; }
body[data-level="y1"]   { --tile-fs: 2rem;    --slot-w: 118px; --slot-h: 74px; }
body[data-level="y2"]   { --tile-fs: 1.7rem;  --slot-w: 108px; --slot-h: 68px; }
body[data-level="y3"]   { --tile-fs: 1.5rem;  --slot-w: 96px;  --slot-h: 64px; }
body[data-level="y4"],
body[data-level="y5"],
body[data-level="y6"]   { --tile-fs: 1.35rem; --slot-w: 84px;  --slot-h: 60px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--navy);
  background: var(--paper);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 20;
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: var(--radius);
}
.skip:focus { top: 12px; }

:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
.skip:focus-visible, .site-header :focus-visible { outline-color: var(--gold); }

button, .word-tile, .slot { user-select: none; -webkit-user-select: none; }

/* ---------- Header ---------- */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.site-header-inner {
  max-width: 960px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 14px;
}
.mark { display: block; width: 46px; height: 42px; flex: none; }
.mark svg { display: block; width: 100%; height: 100%; }
.app-name { font-size: 1.3rem; font-weight: 700; margin: 0; letter-spacing: 0.01em; }

/* ---------- Layout ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px;
}
.panel + .panel { margin-top: 20px; }

h2 { font-size: 1.45rem; line-height: 1.2; margin: 0 0 6px; }
h3 { font-size: 1.1rem; line-height: 1.3; margin: 0 0 4px; }
p { margin: 0; }
.lede { max-width: 62ch; font-size: 1.15rem; color: var(--navy-soft); }
.sub { color: var(--navy-soft); margin-bottom: 18px; max-width: 62ch; }

/* ---------- Start view: hero ---------- */
.hero { padding: 8px 0 30px; }
.hero-line {
  display: inline-flex; align-items: flex-end; flex-wrap: wrap; gap: 10px;
  margin: 0 0 22px; padding-bottom: 14px;
  border-bottom: 4px solid var(--teal);
  font-size: clamp(2rem, 7vw, 3.4rem);
  line-height: 1.1;
}
.hero-tile {
  display: inline-block;
  background: var(--white);
  border: 3px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: 0 4px 0 var(--navy-shadow);
  padding: 0.12em 0.5em 0.16em;
  font-weight: 700;
  animation: settle 0.5s cubic-bezier(.2,.8,.3,1) both;
  animation-delay: calc(var(--i) * 120ms + 80ms);
}
.hero-stop {
  width: 0.3em; height: 0.3em; border-radius: 50%;
  background: var(--gold);
  margin: 0 0 0.16em 0.04em;
  animation: settle 0.5s cubic-bezier(.2,.8,.3,1) both;
  animation-delay: 560ms;
}
@keyframes settle {
  from { opacity: 0; transform: translateY(-18px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Start view: level picker ---------- */
.levels {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px;
}
.levels li { grid-column: span 3; display: flex; }
.levels li:nth-child(-n+3) { grid-column: span 4; }

.level-btn {
  width: 100%;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left;
  font: inherit; color: var(--navy);
  background: var(--white);
  border: 3px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: 0 4px 0 var(--navy-shadow);
  padding: 14px 18px 16px;
  min-height: 112px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.level-btn:hover { box-shadow: 0 4px 0 var(--gold); transform: translateY(-2px); }
.level-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--navy-shadow); }
.level-name { font-size: 1.7rem; font-weight: 700; line-height: 1.15; }
.levels li:nth-child(-n+3) .level-name { font-size: 2rem; }
.level-focus { font-size: 0.98rem; color: var(--navy-soft); }
.level-range { font-size: 0.92rem; font-weight: 700; color: var(--teal-deep); margin-top: auto; padding-top: 6px; }

/* ---------- Start view: how it works ---------- */
.steps {
  list-style: none; margin: 18px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px;
}
.steps li { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: start; align-content: start; }
.step-num {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--navy); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 1.1rem;
}
.steps h3 { align-self: center; }
.steps p { grid-column: 1 / -1; color: var(--navy-soft); }

.notes {
  margin-top: 24px; padding-top: 22px;
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr 1fr; gap: 22px;
}
.notes p { color: var(--navy-soft); }

/* ---------- Builder view ---------- */
.builder { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; }

.top-bar {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; margin-bottom: 18px;
}
.top-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.level-chip {
  margin: 0; font-size: 1.35rem; font-weight: 700;
  padding: 6px 16px; border-radius: 999px;
  background: var(--teal-tint); color: var(--navy);
}
.level-chip:focus { outline: none; }
.level-chip:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
.custom-flag {
  font-size: 0.95rem; font-weight: 700; padding: 4px 12px; border-radius: 999px;
  background: var(--gold-tint); color: var(--navy);
}
.controls-group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

button {
  font-family: inherit; font-size: 1rem; font-weight: 700;
  border: none; border-radius: var(--radius);
  padding: 12px 18px; min-height: 48px;
  cursor: pointer; touch-action: manipulation;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.1s ease, background-color 0.2s;
}
button:active { transform: scale(0.96); }
button svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.btn-secondary { background: var(--navy-tint); color: var(--navy); }
.btn-secondary:hover { background: #d8e3f2; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: #0a4488; }
.btn-success { background: var(--teal-deep); color: #fff; }
.btn-success:hover { background: #035f67; }
.btn-audio { background: var(--navy-tint); color: var(--navy); }
.btn-audio.off { background: #f1f4f8; color: #6b7f99; }

/* Teacher panel */
#teacher-panel {
  display: none;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 20px;
}
#teacher-panel.open { display: block; }
#teacher-panel label { display: block; font-weight: 700; margin-bottom: 8px; }
textarea {
  width: 100%; height: 130px;
  border-radius: 12px; border: 2px solid var(--line);
  padding: 12px; font-size: 1.05rem; font-family: inherit; color: var(--navy);
  margin-bottom: 12px; resize: vertical;
}
textarea:focus { outline: 3px solid var(--navy); outline-offset: 2px; border-color: var(--navy); }
.teacher-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.teacher-status { margin-top: 12px; font-weight: 700; min-height: 1.5em; }
.teacher-status.warn { color: var(--gold-deep); }

.voice-row { margin-top: 18px; padding-top: 16px; border-top: 2px solid var(--line); }
.voice-controls { display: flex; gap: 10px; flex-wrap: wrap; }
select {
  flex: 1; min-width: 220px; min-height: 48px;
  font-family: inherit; font-size: 1.05rem; color: var(--navy);
  background: var(--white); border: 2px solid var(--line); border-radius: 12px;
  padding: 8px 12px;
}
select:focus { outline: 3px solid var(--navy); outline-offset: 2px; border-color: var(--navy); }
.voice-hint { margin-top: 8px; font-size: 0.95rem; color: var(--navy-soft); }

.step-label {
  font-size: 1.1rem; font-weight: 700; color: var(--navy-soft);
  margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}

.word-bank {
  min-height: 90px;
  background: var(--navy-tint);
  border: 2px dashed #9fb4cf;
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: center;
  margin-bottom: 24px;
}

.slots-area {
  min-height: 100px;
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: center;
  margin-bottom: 18px;
}

.slot {
  min-width: var(--slot-w);
  min-height: var(--slot-h);
  border-bottom: 4px solid var(--teal);
  background: var(--white);
  border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px;
  transition: background-color 0.2s, border-color 0.2s, transform 0.15s;
}
.slot.highlight {
  background: var(--gold-tint);
  border-color: var(--gold);
  transform: scale(1.05);
}

.word-tile {
  background: var(--white);
  border: 3px solid var(--navy);
  color: var(--navy);
  font-size: var(--tile-fs);
  font-weight: 700;
  line-height: 1.2;
  padding: 8px 18px;
  border-radius: var(--radius);
  box-shadow: 0 4px 0 var(--navy-shadow);
  cursor: grab;
  touch-action: none;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color 0.25s, border-color 0.25s;
}
.word-tile.dragging {
  position: fixed !important;
  z-index: 9999;
  pointer-events: none;
  transform: scale(1.08);
  box-shadow: 0 12px 24px rgba(8, 54, 108, 0.25);
  opacity: 0.95;
  margin: 0 !important;
}
.word-tile.correct {
  background: var(--teal-tint);
  border-color: var(--teal);
  box-shadow: 0 4px 0 #9fd9de;
}
.word-tile.correct::before {
  content: "";
  width: 0.75em; height: 0.75em; margin-right: 0.35em; flex: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2304727B' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E") center / contain no-repeat;
}
.word-tile.try-again {
  background: var(--gold-tint);
  border-color: var(--gold-deep);
  box-shadow: 0 4px 0 var(--gold);
  animation: gentleWiggle 0.4s ease;
}
@keyframes gentleWiggle {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.feedback-bar {
  min-height: 54px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.feedback-msg {
  font-size: 1.2rem; font-weight: 700;
  padding: 10px 18px; border-radius: var(--radius);
  display: none;
}
.feedback-msg.show { display: inline-block; }
.feedback-msg.info { background: var(--gold-tint); color: var(--navy); }
.feedback-msg.celebrate { background: var(--teal-tint); color: var(--navy); animation: popIn 0.35s ease; }
.feedback-msg.celebrate.show { display: inline-flex; align-items: center; gap: 10px; }
.feedback-msg.celebrate::before {
  content: ""; width: 1.1em; height: 1.1em; flex: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2304727B' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E") center / contain no-repeat;
}
@keyframes popIn {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.typing-section {
  display: none;
  border-top: 2px solid var(--line);
  padding-top: 20px; margin-top: 10px;
  animation: popIn 0.35s ease;
}
.typing-section.unlocked { display: block; }
.typing-input-row { display: flex; gap: 12px; flex-wrap: wrap; }
.typing-input {
  flex: 1; min-width: 240px;
  height: auto; margin: 0; resize: none; line-height: 1.35;
  font-size: 1.45rem; font-weight: 700;
  padding: 14px 18px;
  border: 3px solid var(--navy);
  border-radius: var(--radius);
  font-family: inherit; color: var(--navy);
  background: var(--white);
}
.typing-input:focus { outline: 3px solid var(--navy); outline-offset: 3px; }
.typing-input.done { border-color: var(--teal); background: var(--teal-tint); }

/* Celebration: brand-colour dots (echoing the gold dot in the logo) */
.dot-burst {
  position: fixed; pointer-events: none; z-index: 10000;
  border-radius: 50%;
  animation: floatUp 1.1s ease-out forwards;
}
@keyframes floatUp {
  0% { transform: translateY(0) scale(0.6); opacity: 1; }
  100% { transform: translateY(-130px) scale(1.2); opacity: 0; }
}

/* ---------- Footer ---------- */
.site-footer { background: var(--white); border-top: 1px solid var(--line); }
.site-footer-inner {
  max-width: 960px; margin: 0 auto; padding: 18px 20px;
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 16px;
  color: var(--navy-soft); font-size: 0.95rem;
}
/* The wordmark's bottom edge sits on the text baseline; the lettering sits ~3.65px
   above the swoosh, so nudge it down so the LETTERS share the text baseline. */
.wordmark { display: block; height: 26px; width: auto; position: relative; top: 3.65px; }
.footer-email { margin-left: auto; color: var(--navy); font-weight: 700; text-underline-offset: 3px; }
.footer-email:hover { color: var(--teal-deep); }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .levels li, .levels li:nth-child(-n+3) { grid-column: span 6; }
  .levels li:nth-child(7) { grid-column: span 12; }
  .levels li:nth-child(-n+3) .level-name { font-size: 1.7rem; }
  .steps, .notes { grid-template-columns: 1fr; }
  .panel, .builder { padding: 18px; }
  main { padding: 20px 14px 32px; }
  .footer-email { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-tile, .hero-stop, .typing-section, .feedback-msg.celebrate { animation: none; }
  .level-btn, button, .slot { transition: none; }
  .word-tile.try-again { animation: none; }
}
