/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700&family=Noto+Sans+HK:wght@400;500;600;700&display=swap");

:root {
  --ink: #20201e;
  --muted: #74736c;
  --paper: #f6f3ec;
  --surface: #fffdf8;
  --line: #dcd7cb;
  --accent: #dc5d3f;
  --accent-dark: #a53a27;
  --navy: #183a47;
  --tone-1: #cf4d34;
  --tone-2: #d58a25;
  --tone-3: #34866c;
  --tone-4: #4e70a8;
  --tone-5: #8062a8;
  --tone-6: #726b63;
  --shadow: 0 20px 60px rgb(48 41 28 / 9%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--paper); color: var(--ink); }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", "Noto Sans HK", sans-serif;
  background:
    radial-gradient(circle at 10% 2%, rgb(220 93 63 / 9%), transparent 30rem),
    linear-gradient(90deg, rgb(32 32 30 / 2%) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 64px 64px, auto;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.site-header {
  width: min(1180px, calc(100% - 40px));
  min-height: 88px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--accent);
  font: 600 22px "Noto Sans HK", sans-serif;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .02em; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }

.site-header nav { display: flex; gap: 24px; }
.site-header nav a { color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none; }
.site-header nav a:hover { color: var(--accent-dark); }

main { min-height: calc(100vh - 180px); }

.site-footer {
  width: min(1180px, calc(100% - 40px));
  margin: 80px auto 0;
  padding: 22px 0 32px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.flash, .inline-error {
  width: min(780px, calc(100% - 40px));
  margin: 18px auto;
  padding: 13px 16px;
  border: 1px solid;
  border-radius: 10px;
  font-size: 14px;
}
.flash-notice { color: #276b56; border-color: #9fcbbb; background: #e9f6f0; }
.flash-alert, .inline-error { color: #852e20; border-color: #e4a99c; background: #fff0ec; }
.page-error { margin-bottom: 0; }

.new-lesson-shell, .library-shell, .lesson-shell {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
}

.new-lesson-shell { padding-top: 82px; }
.hero-copy { max-width: 820px; }

.eyebrow {
  margin: 0 0 13px;
  color: var(--accent-dark);
  font: 500 12px "DM Mono", monospace;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.hero-copy h1, .section-heading h1, .lesson-hero h1 {
  margin: 0;
  font-weight: 500;
  letter-spacing: -.045em;
  line-height: 1.05;
}

.hero-copy h1 { max-width: 800px; font-size: clamp(42px, 7vw, 76px); }
.hero-lede { max-width: 690px; margin: 25px 0 0; color: var(--muted); font-size: 19px; line-height: 1.6; }

.generator-card {
  position: relative;
  margin-top: 48px;
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgb(255 253 248 / 92%);
  box-shadow: var(--shadow);
}

.generator-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 40px;
  width: 100px;
  border-top: 3px solid var(--accent);
}

.generator-form label { display: block; font-size: 19px; font-weight: 600; }
.field-hint { margin: 7px 0 18px; color: var(--muted); font-size: 14px; }

.generator-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 190px;
  padding: 20px;
  border: 1px solid #c9c3b6;
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  background: white;
  font-size: 18px;
  line-height: 1.55;
  transition: border .15s, box-shadow .15s;
}

.generator-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgb(220 93 63 / 12%); }
.generator-form textarea::placeholder { color: #a6a197; }

.form-foot { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.form-foot > span { color: var(--muted); font-size: 12px; }

.primary-button, .play-button, .stop-button, .listen-button, .text-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}

.primary-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0 22px;
  color: white;
  background: var(--accent);
  box-shadow: 0 8px 20px rgb(180 64 39 / 18%);
}
.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled { cursor: wait; opacity: .65; }

.feature-row { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 34px; border-block: 1px solid var(--line); }
.feature-row div { position: relative; padding: 25px 24px 25px 45px; }
.feature-row div + div { border-left: 1px solid var(--line); }
.feature-row span { position: absolute; left: 8px; top: 27px; color: var(--accent); font: 500 10px "DM Mono", monospace; }
.feature-row strong, .feature-row small { display: block; }
.feature-row strong { font-size: 14px; }
.feature-row small { margin-top: 4px; color: var(--muted); font-size: 12px; }

.error-list { margin: 12px 0 0; padding-left: 20px; color: #852e20; font-size: 13px; }

.library-shell { padding-top: 64px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; }
.section-heading h1 { font-size: clamp(40px, 6vw, 64px); }
.lesson-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-top: 42px; }

.lesson-card {
  display: block;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: inherit;
  background: var(--surface);
  text-decoration: none;
  transition: transform .15s, box-shadow .15s, border .15s;
}
.lesson-card:hover { transform: translateY(-3px); border-color: #bcb4a5; box-shadow: var(--shadow); }
.lesson-card time { color: var(--muted); font: 400 11px "DM Mono", monospace; text-transform: uppercase; }
.lesson-card h2 { margin: 15px 0 10px; font-size: 23px; }
.lesson-card p { color: var(--muted); font-size: 14px; line-height: 1.55; }
.lesson-card .lesson-card-cantonese { color: var(--ink); font: 500 20px/1.6 "Noto Sans HK", sans-serif; }
.card-link { display: block; margin-top: 22px; color: var(--accent-dark); font-size: 13px; font-weight: 600; }

.empty-state { width: min(580px, calc(100% - 40px)); margin: 100px auto; text-align: center; }
.empty-state > span { display: grid; width: 70px; height: 70px; margin: 0 auto 22px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); font: 600 30px "Noto Sans HK", sans-serif; }
.empty-state h1, .empty-state h2 { margin-bottom: 8px; }
.empty-state p { color: var(--muted); }
.failed-state form { margin-top: 24px; }

.lesson-shell { padding-top: 50px; }
.lesson-hero { padding: clamp(25px, 5vw, 50px); border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.lesson-meta { display: flex; gap: 14px; color: var(--muted); font: 500 10px "DM Mono", monospace; letter-spacing: .1em; text-transform: uppercase; }
.lesson-meta span + span::before { content: "·"; margin-right: 14px; color: var(--accent); }
.lesson-hero h1 { max-width: 800px; margin-top: 23px; font-size: clamp(37px, 6vw, 66px); }
.source-label { margin: 36px 0 8px; color: var(--accent-dark); font: 500 10px "DM Mono", monospace; letter-spacing: .12em; text-transform: uppercase; }
.source-text {
  max-width: 760px;
  margin: 0;
  color: #55534e;
  font: inherit;
  font-size: 17px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.cantonese-panel { margin-top: 28px; padding: 26px 28px; border-left: 3px solid var(--accent); background: #f4ede3; }
.cantonese-panel p { margin: 0; font: 600 clamp(24px, 4vw, 38px)/1.5 "Noto Sans HK", sans-serif; letter-spacing: .02em; }
.cantonese-panel span { display: block; margin-top: 12px; color: var(--muted); font-size: 14px; line-height: 1.5; }

.translation-hero { padding-bottom: clamp(28px, 5vw, 52px); }
.translation-hero .source-label { margin-top: 30px; }
.cantonese-source { color: var(--ink); font-family: "Noto Sans HK", sans-serif; font-size: clamp(20px, 3vw, 28px); }
.translation-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 28px; }
.translation-panel { min-width: 0; padding: 25px 27px; border: 1px solid var(--line); border-radius: 12px; background: #faf7f0; }
.translation-panel.papiamentu-panel { border-top: 3px solid var(--accent); background: #f4ede3; }
.translation-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 13px; }
.translation-label { margin: 0 0 13px; color: var(--accent-dark); font: 500 10px "DM Mono", monospace; letter-spacing: .12em; text-transform: uppercase; }
.translation-panel-heading .translation-label { margin: 0; }
.syllable-toggle { flex: 0 0 auto; padding: 6px 9px; border: 1px solid #cbb9a9; border-radius: 6px; color: var(--accent-dark); background: rgb(255 253 248 / 75%); cursor: pointer; font: 500 10px "DM Mono", monospace; }
.syllable-toggle:hover { border-color: var(--accent); background: var(--surface); }
.syllable-toggle[aria-pressed="true"] { color: white; border-color: var(--accent); background: var(--accent); }
.translation-panel pre { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; font: 500 17px/1.7 "DM Sans", sans-serif; }
.aligned-word { display: inline; margin: 0; padding: 0 1px; border: 0; border-bottom: 1px dotted var(--accent-dark); border-radius: 2px; color: inherit; background: transparent; cursor: pointer; font: inherit; white-space: nowrap; }
.aligned-word:hover, .aligned-word:focus-visible, .aligned-word.is-aligned { outline: 0; color: var(--accent-dark); background: rgb(220 93 63 / 13%); }
.alignment-details { display: grid; grid-template-columns: minmax(60px, auto) auto 1fr; gap: 8px 12px; align-items: baseline; margin-top: 20px; padding: 15px 17px; border: 1px solid #d5c4b3; border-radius: 9px; background: rgb(255 253 248 / 88%); }
.alignment-details > p { grid-column: 1 / -1; margin: 0; color: var(--accent-dark); font: 500 9px "DM Mono", monospace; letter-spacing: .1em; text-transform: uppercase; }
.alignment-details > p span { margin-left: 7px; padding: 3px 6px; border-radius: 999px; color: #755843; background: #eadfce; letter-spacing: 0; text-transform: none; }
.alignment-details strong { font: 600 18px "Noto Sans HK", sans-serif; }
.alignment-details > span:last-child { color: var(--muted); font-size: 14px; }
.alignment-arrow { color: var(--accent); }
.inline-syllabified-word { white-space: nowrap; }
.inline-syllable-separator { padding: 0 1px; color: var(--accent); font-weight: 700; }
.papiamentu-syllable-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--line); }
.papiamentu-syllable-word { padding: 10px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: 500 14px "DM Mono", monospace; box-shadow: 0 4px 12px rgb(48 41 28 / 5%); }
.syllable-separator { padding: 0 2px; color: var(--accent); font-weight: 600; }
.empty-syllables { margin-top: 28px; color: var(--muted); }

.transport { display: flex; align-items: center; gap: 9px; margin-top: 25px; }
.transport select { height: 43px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: white; font: 500 13px "DM Mono", monospace; }
.play-button, .stop-button { min-height: 43px; padding: 0 18px; }
.play-button { color: white; background: var(--navy); }
.stop-button { border: 1px solid var(--line); color: var(--ink); background: transparent; }
.speech-status { margin-left: 8px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.transport audio { display: none; }
.voice-note { margin: 13px 0 0; color: var(--muted); font: 400 10px "DM Mono", monospace; }
.voice-note span { margin-right: 5px; color: var(--accent); font-size: 8px; }

.practice-section { padding-top: 70px; }
.section-heading.compact { align-items: center; }
.section-heading.compact h2 { margin: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.035em; }
.section-heading.compact > p { max-width: 390px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.phrase-list { margin-top: 28px; border-top: 1px solid var(--line); }

.phrase-card { display: grid; grid-template-columns: 55px 1fr; padding: 34px 0; border-bottom: 1px solid var(--line); }
.phrase-number { padding-top: 4px; color: var(--accent); font: 500 11px "DM Mono", monospace; }
.phrase-heading { display: flex; align-items: start; justify-content: space-between; gap: 24px; }
.phrase-heading h3 { margin: 0; font: 600 clamp(22px, 3vw, 29px)/1.45 "Noto Sans HK", sans-serif; }
.phrase-heading p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.listen-button { flex: 0 0 auto; padding: 9px 13px; border: 1px solid var(--line); color: var(--navy); background: var(--surface); font-size: 12px; }
.listen-button:hover { border-color: var(--navy); }

.syllable-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.syllable-tile {
  position: relative;
  display: flex;
  width: 66px;
  min-height: 112px;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px 4px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--ink);
  background: rgb(255 253 248 / 68%);
  cursor: pointer;
  touch-action: manipulation;
  transition: border .12s, background .12s, transform .12s;
}
.syllable-tile:hover { transform: translateY(-2px); border-color: var(--line); background: white; }
.syllable-tile.is-selected { border-color: currentColor; background: white; box-shadow: 0 5px 15px rgb(35 32 25 / 8%); }
.character { color: var(--ink); font: 600 28px/1.25 "Noto Sans HK", sans-serif; }
.jyutping { margin-top: 2px; font: 500 10px "DM Mono", monospace; }
.mini-tone { width: 43px; height: 39px; margin-top: auto; overflow: visible; }
.tone-grid { fill: none; stroke: #ddd7cd; stroke-width: .7; stroke-dasharray: 2 3; }
.tone-line { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.tone-1 { color: var(--tone-1); }
.tone-2 { color: var(--tone-2); }
.tone-3 { color: var(--tone-3); }
.tone-4 { color: var(--tone-4); }
.tone-5 { color: var(--tone-5); }
.tone-6 { color: var(--tone-6); }

.tone-lab { display: grid; grid-template-columns: 230px 1fr 210px; gap: 34px; align-items: center; margin-top: 60px; padding: clamp(25px, 5vw, 48px); border-radius: 16px; color: white; background: var(--navy); }
.tone-visual { color: var(--tone-1); }
.tone-visual svg { display: block; width: 100%; }
.tone-visual .tone-grid { stroke: rgb(255 255 255 / 16%); }
.tone-visual .tone-line { stroke-width: 2.2; vector-effect: non-scaling-stroke; }
.tone-copy .eyebrow { color: #e6a38f; }
.inspector-word { display: flex; align-items: baseline; gap: 13px; }
.inspector-word > span { font: 600 44px "Noto Sans HK", sans-serif; }
.inspector-word strong { font: 500 16px "DM Mono", monospace; }
.inspector-word code { color: #a9c3c9; font: 400 13px "DM Mono", monospace; }
.tone-copy h2 { margin: 14px 0 7px; font-size: 21px; }
.tone-copy > p:last-child { margin: 0; color: #c1d1d5; font-size: 13px; line-height: 1.5; }
.tone-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.tone-legend span { display: flex; align-items: center; gap: 8px; color: #cad7da; font-size: 10px; }
.tone-legend b { display: grid; width: 25px; height: 25px; place-items: center; border: 1px solid currentColor; border-radius: 50%; font: 500 10px "DM Mono", monospace; }

.lesson-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; color: var(--muted); font-size: 11px; }
.text-button { padding: 8px 0; color: var(--accent-dark); background: transparent; font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 800px) {
  .feature-row { grid-template-columns: 1fr; }
  .feature-row div + div { border-top: 1px solid var(--line); border-left: 0; }
  .lesson-grid { grid-template-columns: 1fr; }
  .section-heading.compact { display: block; }
  .section-heading.compact > p { margin-top: 14px; }
  .tone-lab { grid-template-columns: 160px 1fr; }
  .tone-legend { grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 560px) {
  .site-header { width: min(100% - 26px, 1180px); min-height: 72px; }
  .site-header nav { gap: 11px; }
  .site-header nav a { font-size: 11px; }
  .brand-mark { width: 36px; height: 36px; font-size: 18px; }
  .brand small { display: none; }
  .new-lesson-shell, .library-shell, .lesson-shell { width: min(100% - 26px, 1080px); }
  .new-lesson-shell { padding-top: 50px; }
  .hero-copy h1 { font-size: 43px; }
  .hero-lede { font-size: 16px; }
  .generator-card { margin-top: 32px; padding: 22px 17px; }
  .form-foot { align-items: stretch; flex-direction: column; }
  .form-foot > span { order: 2; }
  .library-shell { padding-top: 42px; }
  .library-shell > .section-heading { align-items: start; flex-direction: column; }
  .lesson-shell { padding-top: 22px; }
  .lesson-hero { padding: 24px 18px; }
  .lesson-hero h1 { font-size: 39px; }
  .translation-grid { gap: 12px; margin-top: 22px; }
  .translation-panel { padding: 20px 17px; }
  .translation-panel-heading { align-items: flex-start; }
  .syllable-toggle { min-height: 34px; }
  .alignment-details { grid-template-columns: 1fr; gap: 5px; }
  .alignment-arrow { display: none; }
  .cantonese-panel { padding: 19px; }
  .transport { flex-wrap: wrap; }
  .speech-status { width: 100%; margin: 7px 0 0; }
  .practice-section { padding-top: 48px; }
  .phrase-card { grid-template-columns: 32px 1fr; padding: 27px 0; }
  .phrase-heading { display: block; }
  .listen-button { margin-top: 13px; }
  .syllable-row { gap: 5px; margin-left: -32px; }
  .syllable-tile { width: 61px; min-height: 108px; }
  .tone-lab { grid-template-columns: 1fr; padding: 24px; }
  .tone-visual { max-width: 200px; }
  .tone-legend { grid-column: auto; grid-template-columns: 1fr 1fr; }
  .lesson-actions { align-items: start; flex-direction: column; gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
