/* Fonts of the look (self-hosted, OFL, web/fonts): Lora for the text, Cinzel for titles and capital labels. Variable
   weight 400-700, latin subset (all of Italian). The family names carry a prefix, so a locally installed copy never wins. */
@font-face {
  font-family: "SFD Lora"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/fonts/lora-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "SFD Lora"; font-style: italic; font-weight: 400 700; font-display: swap;
  src: url("/fonts/lora-latin-wght-italic.woff2") format("woff2");
}
@font-face {
  font-family: "SFD Cinzel"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/fonts/cinzel-latin-wght-normal.woff2") format("woff2");
}

/* Look of the Sfida's video cards: cream paper (#FBF6EE -> #EADFCD), gold #9C7633 / #B08A48, ink #2A211B.
   --gold (3.5:1 on the cream) is for large titles, icons and lines; small gold text uses --gold-ink (5.4:1). */
:root {
  --bg: #F4ECDF;
  --bg-top: #FBF6EE;
  --bg-bottom: #EADFCD;
  --card: rgba(255, 253, 248, 0.62);
  --card-hover: rgba(255, 253, 248, 0.94);
  --gold: #9C7633;
  --gold-2: #B08A48;
  --gold-ink: #7A5A22;
  --gold-soft: rgba(156, 118, 51, 0.38);
  --gold-faint: rgba(156, 118, 51, 0.12);
  --text: #2A211B;
  --muted: #675C51;
  --faint: #8A7F73;
  --line: rgba(42, 33, 27, 0.16);
  --danger: #A8362F;
  --ok: #356B44;
  --shadow: rgba(90, 64, 24, 0.16);
  --font-body: "SFD Lora", Georgia, "Times New Roman", serif;
  --font-title: "SFD Cinzel", Georgia, "Times New Roman", serif;
  --radius: 14px;
  --rail: 84px;
  --tabbar: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 15.5px/1.55 var(--font-body);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 520px at 50% -10%, rgba(255, 255, 255, 0.55), transparent 65%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
a { color: var(--gold-ink); }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--font-title); font-weight: 600; letter-spacing: .02em; }
[hidden] { display: none !important; }

.ico {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Navigation */
.nav {
  position: fixed; z-index: 30;
  display: flex;
  background: rgba(251, 246, 238, 0.92);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 10.5px; line-height: 1.15; text-align: center;
  border-radius: 12px; transition: color .2s, background .2s;
}
.nav-btn:hover, .nav-btn:focus-visible { color: var(--text); background: var(--gold-faint); outline: none; }
.nav-btn.active { color: var(--gold-ink); font-weight: 600; }
.nav-btn[aria-disabled="true"], .nav-btn[aria-disabled="true"]:hover { opacity: .35; color: var(--muted); background: transparent; cursor: default; }
body.is-login .nav { display: none; }

/* viewport-fit=cover lets the installed iOS app draw under the status bar and notch: pad for the safe areas. */
@media (min-width: 768px) {
  .nav {
    top: 0; left: 0; bottom: 0; width: calc(var(--rail) + var(--safe-l));
    flex-direction: column; justify-content: center; gap: 10px;
    padding: calc(16px + var(--safe-t)) 8px calc(16px + var(--safe-b)) calc(8px + var(--safe-l));
    border-right: 1px solid var(--gold-soft);
  }
  .nav-btn { width: 100%; padding: 10px 2px; }
  .view { padding: calc(40px + var(--safe-t)) calc(48px + var(--safe-r)) calc(64px + var(--safe-b)) calc(var(--rail) + var(--safe-l) + 48px); }
  body.is-login .view { padding-left: calc(48px + var(--safe-l)); }
}
@media (max-width: 767px) {
  .nav {
    left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar) + var(--safe-b));
    padding: 0 calc(4px + var(--safe-r)) var(--safe-b) calc(4px + var(--safe-l));
    border-top: 1px solid var(--gold-soft);
    justify-content: space-around;
  }
  .nav-btn { flex: 1; min-width: 0; height: var(--tabbar); padding: 6px 2px; font-size: 10px; }
  /* Six tabs on a 320 px phone: a label never spills into its neighbour. */
  .nav-btn span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-btn[data-action="install"] span { font-size: 0; }
  .nav-btn[data-action="install"] span::after { content: "Installa"; font-size: 10px; }
  .view { padding: calc(22px + var(--safe-t)) calc(16px + var(--safe-r)) calc(var(--tabbar) + var(--safe-b) + 28px) calc(16px + var(--safe-l)); }
  body.is-login .view { padding-bottom: calc(28px + var(--safe-b)); }
}

.view { max-width: 1280px; min-height: 100vh; outline: none; }
@media (min-width: 768px) { .view { margin: 0 auto; max-width: calc(1280px + var(--rail)); } }
.page { animation: fadeIn .35s var(--ease) both; }
.page.no-anim { animation: none; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Typography */
.app-name { font-family: var(--font-title); color: var(--gold-ink); font-size: 13px; letter-spacing: .2em; text-transform: uppercase; font-weight: 600; }
.page-title { color: var(--gold); font-size: clamp(22px, 3.2vw, 30px); line-height: 1.25; margin: 6px 0 22px; }
.section-title { color: var(--gold-ink); font-size: 17px; letter-spacing: .06em; margin: 30px 0 14px; }
.muted { color: var(--muted); }
.crumb {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 4px;
  color: var(--muted); font-size: 13.5px; text-decoration: none;
}
.crumb:hover { color: var(--gold-ink); }
.crumb .ico { width: 16px; height: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 20px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; cursor: pointer;
  font-weight: 600; font-size: 15px; text-decoration: none; color: var(--text);
  transition: transform .15s var(--ease), background .2s, border-color .2s, color .2s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: default; }
.btn .ico { width: 19px; height: 19px; }
/* White on deep gold: at least 4.5:1 in the middle of the gradient, where the label sits. */
.btn-gold { background: linear-gradient(180deg, #A47D38, #7A5A22); color: #FFFDF8; box-shadow: 0 6px 16px rgba(122, 90, 34, .22); }
.btn-gold:hover { background: linear-gradient(180deg, #B08A48, #86652A); }
.btn-outline { border-color: var(--gold-soft); color: var(--gold-ink); }
.btn-outline:hover { border-color: var(--gold); background: var(--gold-faint); }
.btn-ghost { background: var(--card); border-color: var(--line); }
.btn-ghost:hover { background: var(--card-hover); }
.btn-block { width: 100%; margin-top: 12px; }
.btn-done { border-color: rgba(53, 107, 68, .45); color: var(--ok); background: rgba(53, 107, 68, .08); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent;
  color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--gold-faint); }

/* Login */
.login {
  min-height: calc(100vh - 80px);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 100%; max-width: 420px; padding: 30px 28px 30px; text-align: center;
  border: 1px solid var(--gold-soft); border-radius: 22px;
  background: rgba(255, 253, 248, .78);
  box-shadow: 0 24px 60px var(--shadow);
}
.login-logo { width: min(240px, 78%); height: auto; margin: 0 auto 2px; }
.login-card p { color: var(--muted); margin: 14px 0 22px; }
.input {
  width: 100%; height: 50px; padding: 0 16px; border-radius: 12px;
  border: 1px solid rgba(42, 33, 27, .22); background: #FFFDF9;
  color: var(--text); font-family: inherit; font-size: 16px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(156, 118, 51, .18); }
.form-error { color: var(--danger); font-size: 14px; margin: 12px 0 0; text-align: left; }
.login-card .login-welcome { margin: 8px 0 16px; font-family: var(--font-title); font-size: 20px; font-weight: 600; letter-spacing: .04em; color: var(--gold-ink); }
.login-label { display: block; color: var(--text); font-weight: 600; font-size: 16px; line-height: 1.4; }
.login-card .login-sub { font-size: 13.5px; margin: 6px 0 16px; }
.form-error-hint { display: block; margin-top: 8px; color: var(--text); opacity: .85; }
.login-help {
  margin-top: 22px; padding: 16px 16px 14px; border-radius: 16px;
  border: 1px solid var(--gold-soft); background: var(--gold-faint);
  transition: border-color .3s, box-shadow .3s;
}
.login-help.is-alert { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-faint); }
.login-card .login-help-title { color: var(--gold-ink); font-weight: 600; font-size: 16px; margin: 0; }
.login-card .login-help-text { color: var(--text); font-size: 14px; margin: 4px 0 0; }
.login-help .btn { white-space: normal; text-align: center; padding: 10px 14px; gap: 7px; font-size: 14.5px; }
.login-help-mail { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 400px) {
  .login-card { padding: 26px 18px 24px; }
  .login-help { padding: 14px 12px 12px; }
}

/* Start page: the logo over the title, then the days of the challenge */
.home-logo { width: min(190px, 54%); height: auto; margin: 0 0 6px; }
.home-intro { color: var(--muted); max-width: 640px; margin: -12px 0 22px; }

/* Days of the challenge: one row per module, open, waiting for its day ("Disponibile domani") or still to come
   ("In arrivo", not clickable). */
.day-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; max-width: 900px; }
.day {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px;
  border: 1px solid var(--gold-soft); border-radius: var(--radius); background: var(--card);
  color: var(--text); text-align: left; text-decoration: none; font: inherit; cursor: pointer;
  transition: border-color .2s, background .2s, box-shadow .2s, transform .2s var(--ease);
}
a.day:hover, a.day:focus-visible { border-color: var(--gold); background: var(--card-hover); box-shadow: 0 10px 26px var(--shadow); outline: none; transform: translateY(-1px); }
.day-mark {
  flex: none; display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%;
  font-family: var(--font-title); font-weight: 700; font-size: 18px; line-height: 1; color: #FFFDF8;
  background: linear-gradient(180deg, var(--gold-2), var(--gold-ink)); box-shadow: 0 4px 12px rgba(122, 90, 34, .25);
}
.day-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.day-label { font-family: var(--font-title); font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-ink); }
.day-title { font-weight: 600; font-size: 16px; line-height: 1.3; overflow-wrap: break-word; overflow-wrap: anywhere; }
.day-meta { margin-top: 3px; font-size: 13px; color: var(--muted); }
.day .progress { max-width: 240px; margin-top: 6px; }
.day-state { flex: none; display: flex; color: var(--gold); }
.day-state .ico { width: 22px; height: 22px; }
.day.done .day-state .ico { stroke-width: 2.4; }
.day.locked { background: rgba(255, 253, 248, .35); border-style: dashed; }
.day.locked .day-mark { background: transparent; color: var(--gold-ink); border: 1px solid var(--gold-soft); box-shadow: none; }
.day.locked .day-title { color: var(--muted); }
.day.locked .day-meta { color: var(--gold-ink); font-weight: 600; }
.day.locked .day-state { color: var(--gold-ink); }
.day.soon { cursor: default; opacity: .78; }
button.day.locked:hover, button.day.locked:focus-visible { border-color: var(--gold); outline: none; }

/* Cards and grids */
.grid { display: grid; gap: 18px; }
.grid-products { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid-modules { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
@media (max-width: 767px) {
  .grid { gap: 12px; }
  .grid-products { grid-template-columns: repeat(2, 1fr); }
  .grid-modules { grid-template-columns: repeat(2, 1fr); }
}

.card {
  position: relative; display: flex; flex-direction: column; justify-content: flex-start;
  width: 100%; padding: 0; text-align: left; font: inherit;
  border: 1px solid var(--gold-soft); border-radius: var(--radius);
  background: var(--card); overflow: hidden; cursor: pointer; color: var(--text); text-decoration: none;
  transition: transform .25s var(--ease), border-color .25s, box-shadow .25s;
}
.card:hover, .card:focus-visible {
  transform: translateY(-3px); border-color: var(--gold); outline: none;
  box-shadow: 0 14px 34px var(--shadow), 0 0 0 1px var(--gold-faint);
}
.cover {
  position: relative; width: 100%; aspect-ratio: 1 / 1; overflow: hidden;
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
}
.cover-tall { aspect-ratio: 9 / 16; }
.cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease), opacity .4s; }
.card:hover .cover img { transform: scale(1.03); }
.cover-fallback {
  position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 14px;
  color: var(--gold-ink); font-family: var(--font-title); font-weight: 600; font-size: 15px; line-height: 1.3;
}
.card-body { padding: 10px 12px 12px; }
.card-title { font-size: 14.5px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Long words wrap (hyphenated where the browser knows the word, lang="it") instead of being cut off. */
.card-title, .page-title, .lesson-title { overflow-wrap: break-word; overflow-wrap: anywhere; -webkit-hyphens: auto; hyphens: auto; }
.card-meta { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.card.locked .cover img, .card.locked .cover-fallback { opacity: .55; filter: grayscale(.35); }
.card.locked .card-title { color: var(--muted); }
.card.locked .card-meta { color: var(--gold-ink); font-weight: 600; }
div.card.locked, div.card.locked:hover { cursor: default; transform: none; box-shadow: none; border-color: var(--gold-soft); }
.lock-badge {
  position: absolute; top: 10px; right: 10px; display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(251, 246, 238, .92); border: 1px solid var(--gold-soft); color: var(--gold-ink);
}
.lock-badge .ico { width: 17px; height: 17px; }
.done-badge {
  position: absolute; top: 10px; right: 10px; display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: #FFFDF8;
}
.done-badge .ico { width: 16px; height: 16px; stroke-width: 2.4; }
/* Product group (unused here): badge on the card, notice above the courses inside */
.age-badge {
  position: absolute; top: 10px; left: 10px; padding: 3px 9px; border-radius: 999px;
  background: rgba(251, 246, 238, .92); border: 1px solid var(--gold); color: var(--gold-ink);
  font-size: 12px; font-weight: 700; letter-spacing: .04em; line-height: 1.3; white-space: nowrap;
}
.group-intro {
  display: flex; gap: 12px; align-items: flex-start; max-width: 900px; margin: -8px 0 22px; padding: 14px 16px;
  border: 1px solid var(--gold-soft); border-radius: var(--radius); background: var(--gold-faint);
}
.group-intro p { margin: 0; line-height: 1.5; }
.age-chip {
  flex: none; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--gold); color: var(--gold-ink);
  font-size: 12px; font-weight: 700; line-height: 1.6; white-space: nowrap;
}

.progress { height: 3px; margin-top: 8px; border-radius: 3px; background: rgba(42, 33, 27, .1); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--gold); border-radius: 3px; transition: width .4s var(--ease); }

/* Continue card */
.continue {
  display: flex; align-items: center; gap: 14px; width: 100%; max-width: 900px; margin: 0 0 8px; padding: 14px 16px;
  border: 1px solid var(--gold-soft); border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(156, 118, 51, .12), rgba(255, 253, 248, .6));
  color: var(--text); text-align: left; cursor: pointer;
  transition: border-color .2s, background .2s;
}
.continue:hover { border-color: var(--gold); }
.continue, .lesson-row { text-decoration: none; }
.cover { flex: none; }
.continue-play {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(180deg, var(--gold-2), var(--gold-ink)); color: #FFFDF8;
}
.continue-play .ico { fill: currentColor; stroke: none; }
.continue-label { font-family: var(--font-title); font-size: 12px; font-weight: 600; color: var(--gold-ink); text-transform: uppercase; letter-spacing: .12em; }
.continue-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue-text { min-width: 0; }

/* Lesson list */
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-width: 900px; }
.lesson-row {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px;
  border: 1px solid rgba(156, 118, 51, .28); border-radius: 12px; background: var(--card);
  color: var(--text); text-align: left; cursor: pointer;
  transition: border-color .2s, background .2s;
}
.lesson-row:hover, .lesson-row:focus-visible { border-color: var(--gold); background: var(--card-hover); outline: none; }
.lesson-num {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--gold-soft); color: var(--gold-ink); font-size: 13px; font-weight: 600;
}
.lesson-type { flex: none; color: var(--faint); }
.lesson-type .ico { width: 18px; height: 18px; }
.lesson-main { flex: 1; min-width: 0; }
.lesson-title { font-weight: 600; line-height: 1.35; }
.lesson-sub { font-size: 12.5px; color: var(--muted); }
.lesson-dur { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lesson-check {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(42, 33, 27, .2); color: transparent;
}
.lesson-check .ico { width: 15px; height: 15px; stroke-width: 2.4; }
.lesson-row.done .lesson-check { background: var(--gold); border-color: var(--gold); color: #FFFDF8; }
.lesson-row.done .lesson-num { background: var(--gold-faint); }
.lesson-row.current { border-color: var(--gold); background: var(--card-hover); }

/* Lesson page (the player stays dark: it is the video's own frame) */
.lesson-page { max-width: 1040px; }
.player {
  position: relative; width: 100%; aspect-ratio: 16 / 9; margin: 0 auto;
  border-radius: var(--radius); overflow: hidden; background: #000;
  border: 1px solid var(--gold-soft); box-shadow: 0 18px 44px rgba(90, 64, 24, .22);
}
/* The Sfida's videos are portrait 3:4 (1080 x 1440). */
.player.vertical { aspect-ratio: 3 / 4; width: min(100%, calc(78vh * 3 / 4)); max-height: 78vh; }
@supports not (aspect-ratio: 1 / 1) {
  .player { height: 0; padding-top: 56.25%; }
  .player.vertical { width: min(100%, 58.5vh); height: 78vh; padding-top: 0; }
}
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-frame { position: relative; width: 100%; height: 75vh; min-height: 420px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--gold-soft); background: #fff; }
.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
@media (max-width: 767px) { .player-frame { height: 65vh; min-height: 320px; } }
/* PDF lesson on a phone or tablet: no iframe, a card with a large button that opens the device's PDF viewer. */
.pdf-card {
  display: flex; flex-direction: column; align-items: center; max-width: 560px; margin: 0 auto; padding: 28px 22px 22px;
  text-align: center; border: 1px solid var(--gold-soft); border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(156, 118, 51, .10), rgba(255, 253, 248, .6));
}
.pdf-card-icon {
  display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%;
  background: var(--gold-faint); border: 1px solid var(--gold-soft); color: var(--gold-ink);
}
.pdf-card-icon .ico { width: 32px; height: 32px; stroke-width: 1.5; }
.pdf-card-text { margin: 14px 0 4px; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.pdf-card .pdf-card-btn { min-height: 56px; font-size: 17px; }
.pdf-card-btn .ico { width: 22px; height: 22px; }
.lesson-head { margin: 20px 0 6px; }
.lesson-head .page-title { margin: 4px 0 0; }
/* The lesson's description (catalog "description", plain text): under the title, after the player or the PDF. */
.lesson-desc { max-width: 760px; margin: 10px 0 0; color: var(--text); font-size: 16px; line-height: 1.65; white-space: pre-line; }
.text-content + .lesson-desc { margin-top: 16px; }
.lesson-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0; }
.lesson-actions .spacer { flex: 1; }
@media (max-width: 767px) {
  .lesson-actions .btn { flex: 1 1 40%; padding: 10px 12px; font-size: 14px; }
  .lesson-actions .btn-toggle { flex-basis: 100%; order: -1; }
  .lesson-actions .spacer { display: none; }
}
/* Text lessons (catalog type "text": the day's instructions, the images to save): long reading, also on a phone.
   .uebung = an exercise box (the class name of the text lessons' markup, shared with the other apps). */
.lesson-head-top { margin: 4px 0 18px; }
.text-content {
  max-width: 760px; padding: 26px 30px 12px; border: 1px solid var(--gold-soft); border-radius: var(--radius);
  background: rgba(255, 253, 248, .72); font-size: 16.5px; line-height: 1.75; color: var(--text);
  overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto;
}
.text-content p, .text-content ul, .text-content ol { margin: 0 0 1.05em; }
.text-content h1, .text-content h2, .text-content h3 { color: var(--gold); line-height: 1.3; -webkit-hyphens: manual; hyphens: manual; }
.text-content h1, .text-content h2 { font-size: 21px; margin: 1.7em 0 .6em; }
.text-content h2::before { content: ""; display: block; width: 36px; height: 1px; margin-bottom: 14px; background: var(--gold-soft); }
.text-content h3 { font-size: 17.5px; color: var(--gold-ink); margin: 1.3em 0 .5em; }
.text-content strong { color: var(--text); font-weight: 700; }
.text-content em { color: #5E4520; }
.text-content ul, .text-content ol { padding-left: 1.35em; }
.text-content li { margin: .4em 0; padding-left: .25em; }
.text-content li::marker { color: var(--gold); }
.text-content ol > li::marker { font-weight: 600; }
.text-content blockquote {
  margin: 1.6em 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--gold);
  font-size: 1.07em; font-style: italic; line-height: 1.6; color: #5E4520;
}
.text-content .uebung {
  margin: 1.8em 0 1.4em; padding: 18px 20px 4px; border: 1px solid var(--gold-soft); border-radius: 12px;
  background: linear-gradient(180deg, rgba(156, 118, 51, .12), rgba(156, 118, 51, .04));
}
.text-content .uebung h3 { margin: 0 0 .55em; font-size: 17px; }
.text-content .uebung h3::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin: 0 10px 2px 0; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 0 4px rgba(156, 118, 51, .18); vertical-align: middle;
}
.text-content hr { height: 1px; margin: 1.8em 0; border: 0; background: var(--gold-soft); }
/* An image to save (portrait 1080 x 1920): whole on the screen, centred. */
.text-content img { width: auto; height: auto; max-height: 80vh; margin: 0 auto 1em; border-radius: 10px; box-shadow: 0 10px 30px var(--shadow); }
.text-content figure { margin: 0 0 1em; }
.text-content iframe { max-width: 100%; }
.text-content > :first-child { margin-top: 0; }
.text-content > h2:first-child::before { display: none; }
@media (max-width: 767px) {
  .text-content { padding: 20px 18px 8px; font-size: 16px; line-height: 1.7; }
  .text-content h1, .text-content h2 { font-size: 19.5px; }
  .text-content .uebung { margin-left: -6px; margin-right: -6px; padding: 16px 16px 2px; }
  .text-content blockquote { padding-left: 14px; }
}

/* Search */
.search-box { position: relative; max-width: 640px; margin-bottom: 20px; }
.search-box .ico { position: absolute; left: 14px; top: 14px; color: var(--faint); }
.search-box .input { padding-left: 46px; }

/* Certificate tab: form and preview side by side on wide screens, stacked on a phone. */
.cert-page { max-width: 1100px; }
.cert-intro { color: var(--muted); max-width: 680px; margin: -10px 0 22px; }
.cert-intro strong { color: var(--text); font-weight: 600; }
.cert-layout { display: grid; gap: 22px; align-items: start; }
@media (min-width: 1024px) { .cert-layout { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 28px; } }
.cert-form { padding: 18px 18px 16px; border: 1px solid var(--gold-soft); border-radius: var(--radius); background: var(--card); }
.cert-label { display: block; font-weight: 600; font-size: 16px; }
.cert-hint { margin: 2px 0 12px; color: var(--muted); font-size: 13.5px; }
.cert-form .form-error { margin: 10px 0 0; }
.cert-form .form-error:empty { margin: 0; }
.cert-form .btn-block { margin-top: 14px; }
.cert-preview {
  position: relative; margin: 0; aspect-ratio: 297 / 210; overflow: hidden;
  border: 1px solid var(--gold-soft); border-radius: 10px; background: rgba(255, 253, 248, .5);
  box-shadow: 0 18px 44px var(--shadow);
}
@supports not (aspect-ratio: 1 / 1) { .cert-preview { height: 0; padding-top: 70.7%; } }
.cert-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: opacity .2s; }
.cert-preview.is-empty { border-style: dashed; box-shadow: none; }
.cert-preview.is-stale img { opacity: .4; }
.cert-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; text-align: center; color: var(--muted); font-size: 14px;
}
.cert-empty .ico { width: 34px; height: 34px; color: var(--gold); stroke-width: 1.4; }
.cert-status { margin: 12px 0 0; color: var(--ok); font-size: 14px; font-weight: 600; }
.cert-status:empty { margin: 0; }
.cert-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.cert-actions .btn { flex: 1 1 210px; }
.cert-note { margin: 10px 0 0; color: var(--muted); font-size: 13.5px; }
/* Scrolled into view after "Create certificate": clear of the bottom tab bar. */
@media (max-width: 767px) { .cert-result { scroll-margin-bottom: calc(var(--tabbar) + var(--safe-b) + 16px); } }

/* States */
.state { max-width: 520px; margin: 48px auto; padding: 30px 24px; text-align: center; border: 1px dashed var(--gold-soft); border-radius: var(--radius); background: rgba(255, 253, 248, .5); color: var(--muted); }
.state h3 { color: var(--text); margin-bottom: 8px; font-size: 17px; }
.state .btn { margin-top: 16px; }

.skel { position: relative; overflow: hidden; background: rgba(42, 33, 27, .07); border-radius: 10px; }
.skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-title { height: 28px; width: 46%; max-width: 360px; margin: 6px 0 24px; }
.skel-card { aspect-ratio: 1 / 1; border-radius: var(--radius); }
.skel-card.tall { aspect-ratio: 9 / 16; }
.skel-row { height: 56px; border-radius: 12px; }
.skel-player { aspect-ratio: 16 / 9; border-radius: var(--radius); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(42, 33, 27, .42); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fade .2s both; }
.modal-card {
  position: relative; width: 100%; max-width: 400px; padding: 26px 22px 22px;
  border: 1px solid var(--gold-soft); border-radius: 20px;
  background: linear-gradient(180deg, #FBF6EE, #F1E7D7);
  box-shadow: 0 30px 80px rgba(42, 33, 27, .3);
  animation: pop .25s var(--ease) both;
}
.modal-card p { margin: 10px 0; }
.modal-title { color: var(--gold); font-size: 20px; padding-right: 36px; }
.modal-x { position: absolute; top: 12px; right: 12px; }
/* The support address (soutien@lecoeurrevient.online) barely fits a 320 px phone: never cut off with an ellipsis, a
   longer one breaks onto a second line (as on the login screen). */
#help-mail { padding-left: 14px; padding-right: 14px; text-align: center; }
#help-mail-text { min-width: 0; overflow-wrap: anywhere; }
/* The help modal grows with the feedback form: it scrolls inside instead of leaving the screen. */
.modal-card { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Feedback (help modal) */
.feedback { margin: 16px 0 0; padding: 16px; border: 1px solid var(--gold-soft); border-radius: var(--radius); background: var(--card); }
.feedback-title { color: var(--gold-ink); font-size: 16px; }
.modal-card .feedback-sub { margin: 4px 0 10px; font-size: 13.5px; }
.modal-card .feedback-sub + .feedback-sub { margin-top: -6px; }
.stars { display: flex; gap: 4px; margin: 0 0 12px -6px; }
.star {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--faint); cursor: pointer;
  transition: color .15s, transform .15s var(--ease), background .2s;
}
.star .ico { width: 28px; height: 28px; stroke-width: 1.5; }
.star:hover, .star:focus-visible { color: var(--gold); background: var(--gold-faint); outline: none; }
.star:active { transform: scale(.92); }
.star.on { color: var(--gold); }
.star.on .ico { fill: currentColor; }
.textarea { display: block; height: auto; min-height: 104px; padding: 12px 16px; line-height: 1.45; font-family: inherit; resize: vertical; }
.feedback .form-error { margin: 10px 0 0; }
.modal-card .feedback-ok { margin: 10px 0 0; color: var(--ok); font-size: 14px; font-weight: 600; }
/* The notices are always-present live regions: empty, they take no space. */
.feedback .form-error:empty, .modal-card .feedback-ok:empty { margin: 0; }
.help-support { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--gold-soft); }
.help-support p { color: var(--muted); font-size: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@media (max-width: 767px) {
  .modal { align-items: flex-end; padding: 0; }
  .modal-card { max-width: none; border-radius: 20px 20px 0 0; padding-bottom: calc(22px + var(--safe-b)); }
}

/* Toasts: dark ink on the cream page */
.toasts {
  position: fixed; z-index: 80; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + var(--safe-b)); width: calc(100% - 32px); max-width: 420px;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
@media (max-width: 767px) { .toasts { bottom: calc(var(--tabbar) + var(--safe-b) + 12px); } }
.toast {
  padding: 12px 16px; border-radius: 12px; font-size: 14px;
  background: rgba(42, 33, 27, .95); border: 1px solid rgba(176, 138, 72, .55); color: #FBF6EE;
  box-shadow: 0 12px 30px rgba(42, 33, 27, .3);
  animation: toastIn .25s var(--ease) both;
}
.toast.error { border-color: rgba(224, 122, 122, .7); }
.toast.hide { opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.summary { color: var(--muted); font-size: 14px; margin: -12px 0 18px; }
.search-box + div .summary { margin: 0 0 12px; }
.search-box + div .grid + .summary { margin-top: 24px; }
.eyebrow { font-family: var(--font-title); font-weight: 600; color: var(--gold-ink); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.media-links { margin-top: 12px; }
.lesson-page .crumb { margin-bottom: 14px; }
.lesson-page .section-title { margin-top: 36px; }

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