/* ==========================================================================
   Mary's English Homework: style.css
   Cream paper, navy serif, teal accents. A playful travel-journal feel.
   Mobile first (375px), light + dark via prefers-color-scheme.
   Optional override: <html data-theme="light|dark"> forces a theme.
   ========================================================================== */

/* ---------- Tokens: light (default) ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f8f3e8;
  --bg-dot: rgba(31, 58, 95, 0.07);
  --card: #fffdf8;
  --card-edge: #e5dac6;
  --shadow: 0 1px 0 rgba(31, 58, 95, 0.04), 0 10px 24px -14px rgba(31, 58, 95, 0.22);

  --heading: #1f3a5f;      /* navy */
  --text: #26323f;
  --muted: #56616d;
  --teal: #2a7469;
  --teal-soft: #d6ebe5;    /* part bars */
  --teal-wash: #edf6f3;    /* boxes, focus fill */
  --ink: #1f6a60;          /* Mary's answers */
  --line: #1f3a5f;         /* handwriting line */
  --rule: rgba(42, 116, 105, 0.22);

  --pill-bg: #1f3a5f;
  --pill-text: #fffdf8;
  --btn-bg: #1f3a5f;
  --btn-text: #fffdf8;
  --btn-shadow: #0e2137;
  --stamp-bg: #f3c34f;     /* "new" badge */
  --stamp-text: #1f3a5f;
  --focus: #2a7469;

  /* Playful accents: decoration only (tape, stickers, chips, highlighter) */
  --sun: #f3c34f;
  --sun-soft: #fcefc6;
  --coral: #e5826b;
  --coral-soft: #fbe3da;
  --sky: #86b6dc;
  --sky-soft: #dfecf7;
  --sticker-ink: #1f3a5f;
}

/* ---------- Tokens: dark (same identity, deep navy night) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1a2b;
    --bg-dot: rgba(240, 231, 214, 0.05);
    --card: #14243a;
    --card-edge: #243a55;
    --shadow: 0 10px 24px -14px rgba(0, 0, 0, 0.7);

    --heading: #f2e9d8;
    --text: #e9e1d1;
    --muted: #b4bcc6;
    --teal: #7fcbbd;
    --teal-soft: #1c3c45;
    --teal-wash: #172f3b;
    --ink: #92d8ca;
    --line: #c8bea9;
    --rule: rgba(127, 203, 189, 0.2);

    --pill-bg: #f2e9d8;
    --pill-text: #0e1a2b;
    --btn-bg: #7fcbbd;
    --btn-text: #0e1a2b;
    --btn-shadow: #3b8579;
    --stamp-bg: #f2cf6e;
    --stamp-text: #0e1a2b;
    --focus: #7fcbbd;

    --sun: #f2cf6e;
    --sun-soft: #3a3424;
    --coral: #f09d87;
    --coral-soft: #3d2a2e;
    --sky: #93c4ea;
    --sky-soft: #1e3450;
    --sticker-ink: #0e1a2b;
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1a2b;
  --bg-dot: rgba(240, 231, 214, 0.05);
  --card: #14243a;
  --card-edge: #243a55;
  --shadow: 0 10px 24px -14px rgba(0, 0, 0, 0.7);

  --heading: #f2e9d8;
  --text: #e9e1d1;
  --muted: #b4bcc6;
  --teal: #7fcbbd;
  --teal-soft: #1c3c45;
  --teal-wash: #172f3b;
  --ink: #92d8ca;
  --line: #c8bea9;
  --rule: rgba(127, 203, 189, 0.2);

  --pill-bg: #f2e9d8;
  --pill-text: #0e1a2b;
  --btn-bg: #7fcbbd;
  --btn-text: #0e1a2b;
  --btn-shadow: #3b8579;
  --stamp-bg: #f2cf6e;
  --stamp-text: #0e1a2b;
  --focus: #7fcbbd;

  --sun: #f2cf6e;
  --sun-soft: #3a3424;
  --coral: #f09d87;
  --coral-soft: #3d2a2e;
  --sky: #93c4ea;
  --sky-soft: #1e3450;
  --sticker-ink: #0e1a2b;
}

/* ---------- Icons (stroke SVGs used as masks, so they follow the theme) ---------- */
:root {
  --i-pencil: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h4L19 9l-4-4L4 16v4z'/%3E%3Cpath d='M13.5 6.5l4 4'/%3E%3C/svg%3E");
  --i-chat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5h11v8H8l-4 3V5z'/%3E%3Cpath d='M15 9h5v9l-3-2.5h-6V13'/%3E%3C/svg%3E");
  --i-bookmark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3h12v18l-6-4-6 4V3z'/%3E%3Cpath d='M9.5 8h5M9.5 11.5h3'/%3E%3C/svg%3E");
  --i-sparkle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 3l1.8 4.7L17.5 9.5l-4.7 1.8L11 16l-1.8-4.7L4.5 9.5l4.7-1.8L11 3z'/%3E%3Cpath d='M18 15l.8 2.2L21 18l-2.2.8L18 21l-.8-2.2L15 18l2.2-.8L18 15z'/%3E%3C/svg%3E");
  --i-headphones: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 15v-3a8 8 0 0 1 16 0v3'/%3E%3Crect x='3' y='14' width='4.5' height='7' rx='1.8'/%3E%3Crect x='16.5' y='14' width='4.5' height='7' rx='1.8'/%3E%3C/svg%3E");
  --i-mic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='3' width='6' height='11' rx='3'/%3E%3Cpath d='M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M9 21h6'/%3E%3C/svg%3E");
  --i-briefcase: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='7' width='18' height='13' rx='2.5'/%3E%3Cpath d='M9 7V5.5A1.5 1.5 0 0 1 10.5 4h3A1.5 1.5 0 0 1 15 5.5V7M3 12.5h18M11 12.5v2h2v-2'/%3E%3C/svg%3E");
  --i-wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 11v2M7 8v8M11 4v16M15 7v10M19 10v4'/%3E%3C/svg%3E");
  --i-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  --i-notebook: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='3' width='14' height='18' rx='2'/%3E%3Cpath d='M9 3v18M12 8h4M12 12h4'/%3E%3C/svg%3E");
  --i-calendar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='5' width='17' height='15' rx='2.5'/%3E%3Cpath d='M3.5 10h17M8 3v4M16 3v4'/%3E%3C/svg%3E");
  --i-squiggle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 10' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M2 6Q8 1 14 5T26 5T38 5T50 5T62 5T70 4'/%3E%3C/svg%3E");
  --i-plane: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 3L3 10.5l7 2.5 2.5 7L21 3z'/%3E%3Cpath d='M10 13l5-5'/%3E%3C/svg%3E");
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1px, transparent 1.3px);
  background-size: 22px 22px;
  color: var(--text);
  font: 400 17px/1.6 "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding:
    max(20px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    calc(56px + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

h1, h2, h3 {
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  color: var(--heading);
  font-optical-sizing: auto;
  font-variation-settings: "SOFT" 100, "WONK" 1; /* Fraunces' rounder, wobblier cut */
}

a { color: var(--teal); }

/* ---------- Header ---------- */
.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 4px;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 9vw, 2.8rem);
  font-weight: 650;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

h1 small {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.15rem, 4.8vw, 1.4rem);
  font-style: italic;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: 0;
}

/* Lesson date above the title, like a little luggage tag */
h1 .when {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  padding: 4px 12px 4px 10px;
  border-radius: 999px;
  background: var(--sun-soft);
  color: var(--heading);
  font: 600 0.95rem/1.3 "Source Sans 3", -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: 0.01em;
  transform: rotate(-2deg);
}
h1 .when::before {
  content: "";
  width: 16px;
  height: 16px;
  background-color: currentColor;
  -webkit-mask: var(--i-calendar) center / contain no-repeat;
  mask: var(--i-calendar) center / contain no-repeat;
}

/* Hand-drawn squiggle instead of a straight underline */
h1::after {
  content: "";
  display: block;
  width: 72px;
  height: 10px;
  margin-top: 12px;
  background-color: var(--teal);
  -webkit-mask: var(--i-squiggle) center / contain no-repeat;
  mask: var(--i-squiggle) center / contain no-repeat;
}

.doodle {
  flex: none;
  width: 84px;
  height: 70px;
  margin-top: 2px;
  color: var(--teal);
}
.doodle .plane { color: var(--heading); }
.doodle .star { color: var(--sun); }
.doodle .dot { color: var(--coral); }

.lead {
  margin: 14px 0 0;
  color: var(--muted);
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin: 0 0 6px -12px;
  padding: 0 14px 0 12px;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
}
.back:hover { background: var(--teal-wash); }

/* ---------- Sections ---------- */
section {
  position: relative;
  margin-top: 32px;
  padding: 18px 16px 18px;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

/* A strip of washi tape "holding" each card to the page; colours rotate */
section::before {
  content: "";
  position: absolute;
  top: -11px;
  left: 22px;
  width: 78px;
  height: 22px;
  background:
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.35) 0 4px, transparent 4px 8px),
    var(--tape, var(--sun));
  opacity: 0.85;
  transform: rotate(-4deg);
  clip-path: polygon(0 8%, 4% 0, 96% 6%, 100% 0, 98% 50%, 100% 100%, 95% 94%, 4% 100%, 0 92%, 2% 50%);
  pointer-events: none;
}
section:nth-of-type(3n + 2)::before { --tape: var(--coral); left: auto; right: 26px; transform: rotate(3deg); }
section:nth-of-type(3n)::before     { --tape: var(--sky);   left: 42%; transform: rotate(-2deg); }

section > h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0 0 14px;
  padding: 5px 12px 5px 5px;
  background: var(--teal-soft);
  border-radius: 22px;
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.25;
}

section > h2 .tag {
  flex: none;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-text);
  font-family: "Source Sans 3", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: rotate(-3deg); /* stuck on like a sticker */
}

/* Section icon: a round sticker at the end of the bar.
   Add class="icon-…" to a <section>; leave it off for no icon. */
section[class*="icon-"] > h2 {
  position: relative;
  padding-right: 54px;
}
section[class*="icon-"] > h2::before,
section[class*="icon-"] > h2::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%) rotate(-8deg);
}
section[class*="icon-"] > h2::before {
  right: 4px;
  width: 40px;
  height: 40px;
  border: 2px dashed var(--teal);
  border-radius: 50%;
  background: var(--card);
}
section[class*="icon-"] > h2::after {
  right: 12px;
  width: 24px;
  height: 24px;
  background-color: var(--teal);
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.icon-pencil     { --icon: var(--i-pencil); }
.icon-chat       { --icon: var(--i-chat); }
.icon-bookmark   { --icon: var(--i-bookmark); }
.icon-sparkle    { --icon: var(--i-sparkle); }
.icon-headphones { --icon: var(--i-headphones); }
.icon-mic        { --icon: var(--i-mic); }
.icon-briefcase  { --icon: var(--i-briefcase); }
.icon-notebook   { --icon: var(--i-notebook); }

section h3 {
  margin: 20px 0 6px;
  font-size: 1.08rem;
  font-weight: 600;
}

section p { margin: 0 0 12px; }

.instructions {
  font-style: italic;
  color: var(--muted);
}

section ol,
section ul {
  margin: 0 0 8px;
  padding-left: 1.5em;
}

section li { margin-bottom: 12px; }

section ol > li::marker {
  color: var(--teal);
  font-weight: 700;
}

/* Sentences with inline gaps get worksheet-style line spacing */
section ol > li:has(input.blank:not(.long)),
.dialogue > li:has(input.blank) {
  line-height: 2.5;
  margin-bottom: 2px;
}

/* ---------- Gap fields: handwritten lines ---------- */
input.blank {
  -webkit-appearance: none;
  appearance: none;
  width: 6.2em;
  max-width: 100%;
  height: 44px;
  margin: 0 2px;
  padding: 12px 6px 0;
  border: 0;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 600 1.4rem/1 "Caveat", "Bradley Hand", "Segoe Print", cursive;
  vertical-align: -4px;
}

input.blank.long {
  display: block;
  width: 100%;
  margin: 0 0 4px;
  padding-left: 2px;
}

/* Focus: a swipe of yellow highlighter behind the line */
input.blank:focus {
  outline: none;
  border-bottom-color: var(--teal);
  background: linear-gradient(to top, transparent 0 2px, var(--sun-soft) 2px 58%, transparent 58%);
}

/* ---------- Text areas: lined journal paper ---------- */
textarea {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-height: calc(36px * 6 + 16px);
  margin-top: 8px;
  padding: 8px 12px;
  border: 1.5px solid var(--card-edge);
  border-radius: 14px;
  background-color: var(--card);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 35px, var(--rule) 35px, var(--rule) 36px);
  background-position: 0 8px;
  background-attachment: local;
  color: var(--ink);
  font: 600 1.4rem/36px "Caveat", "Bradley Hand", "Segoe Print", cursive;
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-wash);
}

/* ---------- Dialogues ---------- */
.dialogue {
  list-style: none;
  padding-left: 0;
}

.dialogue b { color: var(--heading); }

/* Speaker labels (A: / B:) become little round name tags, A teal, B coral */
.dialogue > li:not(:has(textarea)) > b:first-child {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--teal-soft);
  font: 700 0.92rem/1 "Fraunces", Georgia, serif;
  vertical-align: middle;
}
.dialogue > li:nth-child(even):not(:has(textarea)) > b:first-child {
  background: var(--coral-soft);
}

/* ---------- Boxes: phrase bank, prompts, quotes ---------- */
.box {
  margin: 4px 0 16px;
  padding: 12px 14px;
  background: var(--teal-wash);
  border: 1.5px dashed var(--teal);
  border-radius: 14px;
}

.box > b:first-child { color: var(--heading); }

.phrases > b {
  display: block;
  margin-bottom: 10px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.02rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Phrases as a scatter of colourful stickers */
.chips li {
  margin: 0;
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.35;
}
.chips li:nth-child(4n + 1) { background: var(--sun-soft);   transform: rotate(-1.5deg); }
.chips li:nth-child(4n + 2) { background: var(--coral-soft); transform: rotate(1deg); }
.chips li:nth-child(4n + 3) { background: var(--sky-soft);   transform: rotate(-0.5deg); }
.chips li:nth-child(4n)     { background: var(--teal-soft);  transform: rotate(1.5deg); }

/* ---------- Audio player ---------- */
.player {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 16px;
  padding: 10px 12px;
  background: var(--teal-soft);
  border-radius: 16px;
}

.player::before {
  content: "";
  flex: none;
  width: 26px;
  height: 26px;
  background-color: var(--heading);
  -webkit-mask: var(--i-wave) center / contain no-repeat;
  mask: var(--i-wave) center / contain no-repeat;
}

audio {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
}
.player audio { flex: 1; }

/* ---------- Checklist ---------- */
.checklist {
  display: grid;
  gap: 8px;
  margin: 4px 0 14px;
  padding: 0;
  list-style: none;
}

.checklist li { margin: 0; }

.checklist label {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 14px;
  background: var(--card);
  border: 1.5px solid var(--card-edge);
  border-radius: 14px;
  cursor: pointer;
  line-height: 1.35;
}

.checklist input {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: 0;
  border: 2px solid var(--teal);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.checklist input::before {
  content: "";
  width: 16px;
  height: 16px;
  background-color: var(--card);
  -webkit-mask: var(--i-check) center / contain no-repeat;
  mask: var(--i-check) center / contain no-repeat;
  transform: scale(0);
  transition: transform 0.25s cubic-bezier(0.3, 1.8, 0.5, 1); /* little pop */
}

.checklist input:checked { background: var(--teal); }
.checklist input:checked::before { transform: scale(1); }
.checklist label:has(input:checked) {
  border-color: var(--sun);
  background: var(--sun-soft);
}

.checklist input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Buttons ---------- */
.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 32px;
}

button {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 24px;
  border: 2px solid var(--btn-bg);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font: 600 1.05rem/1.2 "Source Sans 3", -apple-system, BlinkMacSystemFont, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 0 var(--btn-shadow); /* chunky "press me" edge */
  margin-bottom: 4px;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

#send::before {
  content: "";
  width: 20px;
  height: 20px;
  background-color: currentColor;
  -webkit-mask: var(--i-plane) center / contain no-repeat;
  mask: var(--i-plane) center / contain no-repeat;
}

button.secondary {
  border: 2px dashed var(--teal);
  background: transparent;
  color: var(--heading);
  box-shadow: none;
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--btn-shadow);
}
button.secondary:active { box-shadow: none; }

button:focus-visible,
.back:focus-visible,
.list a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

@media (min-width: 560px) {
  .actions { flex-direction: row; }
}

/* ---------- Home: homework cards ---------- */
.list {
  display: grid;
  gap: 16px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.list li { margin: 0; }

.list a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 88px;
  padding: 16px 40px 16px 14px;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 18px;
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
}

.list a::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 18px;
  width: 9px;
  height: 9px;
  border-top: 2px solid var(--teal);
  border-right: 2px solid var(--teal);
  transform: translateY(-50%) rotate(45deg);
}

.list a {
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.list a:hover {
  border-color: var(--teal);
  transform: translateY(-2px) rotate(-0.4deg);
}

/* Lesson date as a little postage-stamp sticker; colours rotate */
.list .stamp {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 70px;
  border-radius: 12px;
  background: var(--stamp-col, var(--sun));
  color: var(--sticker-ink);
  outline: 1.5px dashed var(--sticker-ink);
  outline-offset: -5px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
  transform: rotate(-5deg);
  text-align: center;
}
.list .stamp .d {
  font: 650 1.6rem/1 "Fraunces", Georgia, serif;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}
.list .stamp .m {
  margin-top: 3px;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.02em;
}
.list .stamp .y {
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.1;
}
.list li:nth-child(3n + 2) .stamp { --stamp-col: var(--coral); transform: rotate(4deg); }
.list li:nth-child(3n)     .stamp { --stamp-col: var(--sky);   transform: rotate(-2deg); }

.list .card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.list .title {
  color: var(--heading);
  font: 600 1.12rem/1.3 "Fraunces", Georgia, serif;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}

.list .topic {
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.4;
}

.list .is-new a { border-color: var(--teal); }

.list .badge {
  position: absolute;
  top: -10px;
  right: 14px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--stamp-bg);
  color: var(--stamp-text);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
  transform: rotate(6deg);
  animation: wiggle 0.6s ease-in-out 0.4s 2;
}

.list .badge::before { content: "\2726\00a0"; } /* ✦ */

/* ---------- Lesson material: pictures + words ---------- */

/* Pictures: one is full width; several become a swipeable strip */
.gallery {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 -16px 18px;
  padding: 4px 16px 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 16px;
  -webkit-overflow-scrolling: touch;
}

.gallery figure {
  flex: 0 0 86%;
  margin: 0;
  scroll-snap-align: start;
}
.gallery figure:only-child { flex-basis: 100%; }

.gallery a {
  display: block;
  padding: 6px 6px 0;
  border-radius: 10px;
  background: #fff;                    /* white photo frame, even in dark mode */
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05), 0 8px 18px -10px rgba(0, 0, 0, 0.4);
  transform: rotate(-1deg);
}
.gallery figure:nth-child(even) a { transform: rotate(1.2deg); }

.gallery img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.gallery figcaption {
  padding: 8px 4px 0;
  color: var(--muted);
  font: 600 1.15rem/1.2 "Caveat", "Bradley Hand", cursive;
  text-align: center;
}

/* Words & collocations as sticky notes from the lesson board */
.words {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 0;
}

.word {
  padding: 10px 12px 12px;
  border-radius: 4px 4px 14px 4px;
  background: var(--note, var(--sun-soft));
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06), 0 6px 12px -8px rgba(0, 0, 0, 0.35);
  transform: rotate(var(--tilt, -1deg));
}
.word:nth-child(4n + 2) { --note: var(--coral-soft); --tilt: 1.2deg; }
.word:nth-child(4n + 3) { --note: var(--sky-soft);   --tilt: -0.6deg; }
.word:nth-child(4n)     { --note: var(--teal-soft);  --tilt: 0.8deg; }
.word.wide { grid-column: 1 / -1; }   /* for longer notes or examples */

.word dt {
  color: var(--heading);
  font: 650 1.05rem/1.25 "Fraunces", Georgia, serif;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}

.word dd { margin: 4px 0 0; line-height: 1.4; }

.word .tr {           /* translation */
  color: var(--text);
  font-size: 0.95rem;
}

.word .eg {           /* example sentence */
  color: var(--ink);
  font-weight: 600;
  border-left: 3px solid var(--teal);
  padding-left: 8px;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(6deg); }
  25%      { transform: rotate(-6deg) scale(1.08); }
  75%      { transform: rotate(10deg); }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Picture viewer ---------- */
.viewer {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 56px 12px 12px;
  border: 0;
  background: rgba(14, 26, 43, 0.92);
  overflow: auto;
}
.viewer::backdrop { background: transparent; }
.viewer img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: auto;
  border-radius: 8px;
}
.viewer button {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.6rem;
  line-height: 1;
}

/* ---------- Voice alternative under writing tasks ---------- */
.voice-option {
  margin: -4px 0 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--teal-wash);
  color: var(--text);
}
.voice-option b { color: var(--teal); }

/* ---------- Play button on word examples ---------- */
.word .say {
  display: inline-flex;
  flex: none;
  vertical-align: middle;
  width: 34px;
  height: 34px;
  min-height: 0;
  margin: 0 0 0 6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: none;
}
.word .say::before {
  content: "";
  width: 14px;
  height: 14px;
  margin-left: 3px;
  background: var(--card);
  -webkit-mask: var(--i-play) center / contain no-repeat;
  mask: var(--i-play) center / contain no-repeat;
}
:root {
  --i-play: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 3.5v17a1 1 0 0 0 1.5.86l14-8.5a1 1 0 0 0 0-1.72l-14-8.5A1 1 0 0 0 6 3.5z'/%3E%3C/svg%3E");
}

/* ---------- Tap-to-reveal translation ---------- */
.reveal summary {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 12px;
  border: 1.5px solid var(--teal);
  border-radius: 999px;
  color: var(--teal);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.reveal summary::-webkit-details-marker { display: none; }
.reveal[open] summary { background: var(--teal); color: var(--card); }
.reveal p { margin: 6px 0 0; color: var(--text); }

/* ---------- Roleplay: characters, topic choice, speaker lines ---------- */
:root {
  --i-bag: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8h14l-1 12H6L5 8z'/%3E%3Cpath d='M9 8V6a3 3 0 0 1 6 0v2'/%3E%3C/svg%3E");
}
.icon-plane { --icon: var(--i-plane); --chip: var(--teal); --chip-soft: var(--teal-wash); }
.icon-bag   { --icon: var(--i-bag);   --chip: var(--coral); --chip-soft: var(--coral-soft); }

.roleplay-cast {
  display: block;
  width: 100%;
  height: auto;
  margin: 12px 0;
  border-radius: 12px;
}

.topics-label { margin: 12px 0 8px; font-weight: 600; color: var(--heading); }
.topics { list-style: none; padding: 0; display: grid; gap: 10px; }
.topics li { margin: 0; }
.topics label {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 14px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--chip-soft);
  cursor: pointer;
  position: relative;
}
.topics label::before {
  content: "";
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--chip);
}
.topics label::after {
  content: "";
  position: absolute;
  left: 23px;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translateY(-50%);
  background: var(--card);
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.topics input { position: absolute; opacity: 0; pointer-events: none; }
.topics label:has(input:checked) { border-color: var(--chip); }
.topics label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }

.roleplay-lines {
  list-style: none;
  padding: 12px 14px;
  border: 1.5px solid var(--teal);
  border-radius: 14px;
}
.roleplay-lines li { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.roleplay-lines .blank.long { flex: 1; margin-top: 0; }
.speaker {
  flex: none;
  padding: 2px 10px;
  border-radius: 8px;
  font-weight: 700;
  color: var(--heading);
}
.speaker-0 { background: var(--sky-soft); }
.speaker-1 { background: var(--coral-soft); }
