/* Traducteur PDF: the page images stay white like paper; the rest follows the theme. */
:root {
  --bg: #eef1f6;
  --panel: #ffffff;
  --text: #142039;
  --muted: #5b6880;
  --line: #d4dbe7;
  --accent: #1a7fa3;
  --accent-text: #ffffff;
  --gold: #b7791f;
  --gold-soft: #fff4dc;
  --bar: #0f1726;
  --bar-text: #f3f7ff;
  --bar-line: #34445f;
  --mark: #ffe08a;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b111d;
    --panel: #131c2d;
    --text: #eef3fc;
    --muted: #9aa8c0;
    --line: #29364d;
    --accent: #3fb6dc;
    --accent-text: #06121c;
    --gold: #ffcc66;
    --gold-soft: #2a2414;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* The scrollbar appearing with the pages must not change the width they were sized for. */
  scrollbar-gutter: stable;
}

.lang {
  display: inline-block;
  min-width: 1.9em;
  margin-right: .35em;
  padding: 0 .3em;
  border-radius: .3em;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-size: .72em;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  vertical-align: .12em;
}

.lang.fr {
  background: color-mix(in srgb, var(--gold) 20%, transparent);
  color: var(--gold);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button {
  font: inherit;
  cursor: pointer;
}

/* ─── Top bar ─────────────────────────────────────────────────────────────── */

.bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .8rem;
  padding: calc(.5rem + env(safe-area-inset-top, 0px)) 1rem .5rem;
  background: var(--bar);
  color: var(--bar-text);
  box-shadow: 0 2px 10px rgb(0 0 0 / .25);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .2rem .3rem;
  border: 0;
  border-radius: .5rem;
  background: transparent;
  color: inherit;
  font-weight: 700;
}

.brand img {
  display: block;
}

.doc-title {
  flex: 1 1 10rem;
  min-width: 0;
}

.doc-title strong {
  display: block;
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #c9d5ea;
}

body:not(.reading) .reader-only {
  display: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-left: auto;
}

.modes,
.zoom {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--bar-line);
  border-radius: .6rem;
}

.modes button,
.zoom button,
.words-button {
  min-width: 2.6rem;
  min-height: 2.3rem;
  padding: .25rem .6rem;
  border: 0;
  border-right: 1px solid var(--bar-line);
  background: transparent;
  color: var(--bar-text);
}

.modes button:last-child,
.zoom button:last-child {
  border-right: 0;
}

.modes button[aria-pressed="true"] {
  background: #1a7fa3;
  color: #fff;
}

.words-button {
  border: 1px solid #8a6a2a;
  border-radius: .6rem;
  background: #2b2414;
  color: #ffd98a;
}

.words-button[aria-expanded="true"] {
  background: #ffcc66;
  color: #1d1606;
}

.badge {
  display: inline-block;
  min-width: 1.4rem;
  padding: 0 .35rem;
  border-radius: 999px;
  background: #ffcc66;
  color: #1d1606;
  font-size: .75rem;
  font-weight: 700;
  text-align: center;
}

.words-button[aria-expanded="true"] .badge {
  background: #1d1606;
  color: #ffcc66;
}

/* ─── Messages ────────────────────────────────────────────────────────────── */

.status,
.notice {
  max-width: 60rem;
  margin: .7rem auto;
  padding: 0 1rem;
  color: var(--muted);
  font-size: .9rem;
}

.status:empty {
  display: none;
}

.notice {
  padding: .7rem 1rem;
  border: 1px solid #d9a21b;
  border-radius: .7rem;
  background: var(--gold-soft);
  color: var(--text);
}

/* ─── Home ────────────────────────────────────────────────────────────────── */

.home {
  display: grid;
  gap: 1rem;
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

.hero h1 {
  margin: .6rem 0 .4rem;
  font-size: clamp(1.5rem, 5vw, 2.1rem);
  line-height: 1.2;
}

.hero h1 span {
  display: block;
  color: var(--accent);
}

.hero > p {
  margin: 0 0 1rem;
  color: var(--muted);
}

.drop {
  display: grid;
  place-items: center;
  gap: .3rem;
  min-height: 9rem;
  padding: 1.2rem;
  border: 2px dashed var(--accent);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
  text-align: center;
  cursor: pointer;
  transition: background .15s;
}

.drop:hover,
.drop.over {
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
}

.drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop:focus-within {
  outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent);
}

.drop strong {
  font-size: 1.2rem;
}

.drop span {
  color: var(--muted);
  font-size: .9rem;
}

.url-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .4rem;
  margin-top: 1rem;
}

.url-row label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: .9rem;
}

.url-row input {
  min-width: 0;
  min-height: 2.6rem;
  padding: .4rem .7rem;
  border: 1px solid var(--line);
  border-radius: .6rem;
  background: var(--panel);
  color: inherit;
  font: inherit;
}

.url-row button,
.install button,
.drawer-tools button,
.review-actions button {
  min-height: 2.6rem;
  padding: 0 1rem;
  border: 0;
  border-radius: .6rem;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.card {
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
}

.card h2 {
  margin: 0 0 .5rem;
  font-size: 1.1rem;
}

.card p {
  margin: .3rem 0;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.access {
  border-color: #d9a21b;
}

.library {
  display: grid;
  gap: .4rem;
  margin: .5rem 0 0;
  padding: 0;
  list-style: none;
}

.library li {
  display: flex;
  gap: .4rem;
}

.library .doc {
  display: grid;
  flex: 1;
  min-width: 0;
  padding: .55rem .75rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  background: transparent;
  color: inherit;
  text-align: left;
}

.library .doc:hover {
  border-color: var(--accent);
}

.library .doc strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library .doc small {
  color: var(--muted);
}

.icon {
  min-width: 2.5rem;
  border: 1px solid var(--line);
  border-radius: .6rem;
  background: transparent;
  color: inherit;
}

.link {
  padding: .2rem 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-align: left;
}

.small {
  color: var(--muted);
  font-size: .85rem;
}

.privacy {
  text-align: center;
}

/* ─── Reader ──────────────────────────────────────────────────────────────── */

#pages {
  display: grid;
  gap: 1.2rem;
  justify-items: center;
  padding: .8rem .5rem 4.5rem;
}

.page {
  display: grid;
  gap: .5rem;
  justify-items: center;
}

.page-pair {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  justify-content: center;
}

.sheet {
  position: relative;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 12px rgb(0 0 0 / .18);
}

.sheet canvas {
  display: block;
}

.sheet .label {
  position: absolute;
  top: .3rem;
  right: .3rem;
  z-index: 3;
  padding: .05rem .4rem;
  border-radius: .4rem;
  background: rgb(15 23 38 / .72);
  color: #fff;
  font-size: .7rem;
  pointer-events: none;
}

/* The FR sheet copies the original page and paints each paragraph in French over it. */
.overlay {
  position: absolute;
  inset: 0;
}

.block {
  position: absolute;
  overflow: hidden;
  color: #111;
  font-family: "Latin Modern Roman", "CMU Serif", "Times New Roman", Times, Georgia, serif;
  cursor: pointer;
}

.block-text {
  position: absolute;
  top: 0;
  left: 0;
  font-size: 16px;
  line-height: 1.13;
  text-align: justify;
  hyphens: auto;
  overflow-wrap: anywhere;
  transform-origin: 0 0;
}

.block.heading .block-text {
  font-weight: 700;
  text-align: left;
}

.block.dark {
  color: #f5f5f5;
}

.block.show-en {
  outline: 2px solid rgb(26 127 163 / .7);
  outline-offset: 1px;
}

.block mark {
  border-radius: 2px;
  background: var(--mark);
  color: #111;
}

.page-status {
  margin: 0;
  color: var(--muted);
  font-size: .8rem;
}

.page-status button {
  margin-left: .4rem;
  border: 1px solid var(--line);
  border-radius: .4rem;
  background: transparent;
  color: inherit;
}

body.mode-en .sheet.fr,
body.mode-fr .sheet.en {
  /* Kept in the layout (offscreen) so French paragraphs can still be measured. */
  position: absolute;
  left: -300vw;
  visibility: hidden;
}

.foot {
  position: fixed;
  right: .8rem;
  bottom: calc(.8rem + env(safe-area-inset-bottom, 0px));
  z-index: 15;
  padding: .35rem .75rem;
  border-radius: 999px;
  background: rgb(15 23 38 / .88);
  color: #fff;
  font-size: .8rem;
}

/* ─── Words drawer ────────────────────────────────────────────────────────── */

.drawer {
  position: fixed;
  top: var(--bar-height, 3.4rem);
  right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  width: min(420px, 100vw);
  border-left: 1px solid var(--line);
  background: var(--bg);
  box-shadow: -6px 0 24px rgb(0 0 0 / .18);
}

@media (min-width: 1100px) {
  body.drawer-open.reading #pages {
    margin-right: 420px;
  }
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem .7rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.tabs {
  display: flex;
  flex: 1;
  gap: .3rem;
}

.tabs button {
  flex: 1;
  min-height: 2.4rem;
  padding: 0 .5rem;
  border: 1px solid var(--line);
  border-radius: .6rem;
  background: transparent;
  color: inherit;
}

.tabs button[aria-selected="true"] {
  border-color: var(--gold);
  background: var(--gold-soft);
  font-weight: 700;
}

.close {
  min-width: 2.4rem;
  min-height: 2.4rem;
  border: 0;
  border-radius: .6rem;
  background: transparent;
  color: inherit;
  font-size: 1.1rem;
}

.drawer-tools {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .6rem .7rem 0;
}

.word-list {
  display: grid;
  align-content: start;
  gap: .7rem;
  overflow-y: auto;
  padding: .7rem .7rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  overscroll-behavior: contain;
}

.word-list > .small,
.empty {
  margin: 0;
}

.empty {
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}

.word {
  padding: .8rem .9rem;
  border: 1px solid var(--line);
  border-radius: .9rem;
  background: var(--panel);
}

.word.top {
  border: 2px solid var(--gold);
  background: linear-gradient(var(--gold-soft), var(--panel) 70%);
}

.word-badge {
  margin: 0 0 .3rem;
  color: var(--gold);
  font-size: .8rem;
  font-weight: 700;
}

.word-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .5rem;
}

.word h3,
.review h3 {
  margin: 0;
  font-size: 1.25rem;
}

.ipa {
  color: var(--muted);
  font-family: "Segoe UI", "Lucida Sans Unicode", "DejaVu Sans", sans-serif;
}

.word-head .icon {
  min-width: 2rem;
  min-height: 2rem;
  padding: 0;
}

.kind {
  padding: .05rem .5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-size: .75rem;
}

.word-fr {
  margin: .35rem 0 .2rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.word-def {
  margin: 0 0 .4rem;
  color: var(--muted);
}

.example {
  margin: .4rem 0;
  padding: .4rem .7rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 .5rem .5rem 0;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.example p {
  margin: .15rem 0;
  font-size: .9rem;
}

.example .fr {
  color: var(--muted);
}

.word-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
  margin-top: .4rem;
}

.word-foot .link {
  font-size: .85rem;
}

.save {
  min-height: 2.2rem;
  padding: 0 .8rem;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: transparent;
  color: var(--gold);
  font-weight: 600;
}

.save.saved {
  background: var(--gold);
  color: var(--panel);
}

.review {
  margin: .7rem .7rem 0;
  padding: 1rem;
  border: 2px solid var(--accent);
  border-radius: 1rem;
  background: var(--panel);
  text-align: center;
}

.review .answer {
  margin-top: .5rem;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .4rem;
  margin-top: .8rem;
}

@media (max-width: 600px) {
  .bar {
    padding-inline: .6rem;
  }

  .brand span {
    display: none;
  }

  body:not(.reading) .brand span {
    display: inline;
  }

  .controls {
    width: 100%;
    margin-left: 0;
  }

  .modes {
    flex: 1;
  }

  .modes button {
    flex: 1;
  }

  .drawer {
    border-left: 0;
  }
}
