/* 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: #07356B;
  --navy-soft: #46576C;
  --navy-tint: #E8EFF8;
  --navy-shadow: #B9C9DD;
  --teal: #059FAA;
  --teal-deep: #04727B;
  --teal-tint: #E3F3F5;
  --gold: #FBB525;
  --gold-deep: #C27E00;
  --gold-tint: #FFF1CC;
  --paper: #F4F9FB;
  --white: #FFFFFF;
  --line: #D3E1E9;
  --radius: 14px;
  --radius-lg: 16px;

  --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%; }

html { padding-top: env(safe-area-inset-top, 0px); scroll-padding-top: env(safe-area-inset-top, 0px); }
html[data-size="2"] { font-size: 112.5%; }
html[data-size="3"] { font-size: 125%; }
html[data-space="wide"] body { line-height: 1.95; letter-spacing: .03em; word-spacing: .12em; }
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 { outline-color: var(--gold); }
.hero :focus-visible { outline-color: #fff; }

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

/* ---------- Header (shared with the AmicaEd Australia landing page) ---------- */
/* ---------- Layout ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }
main { flex: 1; width: 100%; padding: 0 0 40px; }
#start-view > .panel, .builder { width: calc(100% - 2.5rem); max-width: 1080px; margin: 28px auto 0; }
#start-view > .panel + .panel { margin-top: 20px; }
.panel, .builder { background: var(--white); border: 1px solid var(--line); border-top: 6px solid var(--gold); border-radius: var(--radius-lg); padding: 26px; }
.builder { padding: 24px; }

h1, h2, h3, .level-name { font-family: "Bricolage Grotesque", "Atkinson Hyperlegible", system-ui, sans-serif; }
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 (navy band with white tiles, as on the landing page) ---------- */
.hero { background: var(--navy); color: #fff; padding: clamp(1.75rem, 4vw, 3rem) max(1.25rem, calc((100% - 1080px) / 2 + 1.25rem)) clamp(2rem, 5vw, 3.5rem); }
.crumb { margin: 0 0 1rem; font-weight: 700; }
.crumb a { color: var(--gold); }
.hero-line {
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: .18em .22em;
  margin: 0 0 1.25rem; font-size: clamp(2.1rem, 6.2vw, 4.1rem); line-height: 1.1;
  font-family: "Bricolage Grotesque", "Atkinson Hyperlegible", system-ui, sans-serif; font-weight: 800;
}
.hero-tile {
  display: inline-block; background: #fff; color: var(--navy);
  border-radius: .2em; box-shadow: 0 .09em 0 var(--teal);
  padding: .04em .3em .1em; font-weight: 800;
  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; } }
.hero .lede { color: #e3edf8; }

/* ---------- 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 ---------- */

.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; }
}

/* ---------- 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; }
  #start-view > .panel, .builder { width: calc(100% - 1.75rem); }
}

@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; }
}

/* ---------- Site header and footer (same as the landing page) ---------- */
.site-header-inner { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: 1rem; padding-bottom: 1rem; }
.logo { display: inline-block; padding: .35rem .7rem; border-radius: 10px; line-height: 0; }
.logo-svg { display: block; height: 2.3rem; width: 10.43rem; }
nav.main { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
nav.main a { color: var(--navy); text-decoration: none; font-weight: 700; }
nav.main a:hover { text-decoration: underline; text-underline-offset: .25em; }
.rs-btn, .rs-panel button { font-weight: 400; color: var(--navy); background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: .35rem .9rem; min-height: 0; }
.rs-btn[aria-expanded="true"], .rs-panel button[aria-pressed="true"] { border-color: var(--teal-deep); background: var(--teal-tint); }
.rs-panel { position: absolute; right: 0; top: 100%; z-index: 25; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1rem; display: grid; gap: .75rem; box-shadow: 0 12px 30px rgba(7,53,107,.18); min-width: 15rem; }
.rs-panel .row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.rs-panel .row > span { flex: 1 0 100%; font-weight: 700; }
footer.site { border-top: 1px solid var(--line); padding: 2rem 0 2.5rem; margin-top: 2rem; }
footer.site .row { display: flex; gap: 1rem 2rem; flex-wrap: wrap; align-items: baseline; justify-content: space-between; }
footer.site .brand { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
footer.site .logo-svg.foot { height: 1.8rem; width: 8.17rem; display: inline-block; vertical-align: baseline; transform: translateY(.257rem); }
footer.site small { font-size: .95rem; color: var(--navy-soft); }
footer.site a { font-weight: 700; color: var(--navy); }
