/* La page est une ziggourat : on écrit sur la tablette d'argile à la base, et chaque traduction
   est un étage émaillé, plus étroit, posé au-dessus. Ciel abricot en haut, terre sombre en bas.
   Un seul thème, voulu : les couleurs de la tour ne changent pas. */
:root {
  --sky: #f3ab7a;
  --sun: #f9d27d;
  --clay: #efdcb8;
  --clay-line: #c9ad7c;
  --earth: #24150c;
  --earth-2: #35210f;
  --earth-line: #5a3d22;
  --sand: #f0e2c6;
  --sand-soft: #c7b393;
  --gold: #e0a32e;
  --ink: #1a1208;
  --ink-soft: #5e4a2c;
  --error: #8f1d10;
  --display: "Gloock", Georgia, serif;
  --ui: "Familjen Grotesk", "Segoe UI", Arial, sans-serif;
  --text: "Newsreader", Georgia, "Times New Roman", serif;
  --step: 44px;
  --chev-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M1 3l5 6 5-6z' fill='%231a1208'/%3E%3C/svg%3E");
  --chev-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M1 3l5 6 5-6z' fill='%23ffffff'/%3E%3C/svg%3E");
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--earth); color: var(--ink); font: 400 16px/1.45 var(--ui); }
button, select, input, textarea { font: inherit; color: inherit; }
button, label[for^="file"] { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

select {
  appearance: none; field-sizing: content; border: 0; cursor: pointer; min-width: 0; max-width: 100%;
  padding: 0 18px 0 0; background: var(--chev-dark) no-repeat right center / 10px;
}
select option { color: var(--ink); background: #fff; font: 400 16px var(--ui); }

/* Ciel */
.sky {
  position: relative; overflow: hidden; background: var(--sky);
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.sun { position: absolute; top: -70px; right: 9%; width: 300px; height: 300px; border-radius: 50%; background: var(--sun); }
.top { position: relative; display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-block: 14px 8px; max-width: 1180px; margin: 0 auto; }
.name { font: 400 clamp(2.6rem, 6vw, 4.2rem)/1 var(--display); color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.top nav { display: flex; gap: 18px; font-weight: 600; }
.top nav a { color: var(--ink); text-decoration: none; border-bottom: 2px solid transparent; }
.top nav a:hover { border-color: var(--ink); }

/* Tour */
.tower { position: relative; max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; }
#floors { width: 100%; display: flex; flex-direction: column; align-items: center; }

.floor, .ghost {
  width: calc(100% - var(--n, 1) * var(--step) * 2);
}
.ghost {
  --n: 1; min-height: 46px; background: none; border: 2px dashed var(--ink); border-bottom: 0;
  font-weight: 700; color: var(--ink);
}
.ghost:hover { background: rgb(26 18 8 / 0.08); }

.floor { position: relative; color: var(--on, #fff); background: var(--tile); --chev: var(--chev-light); }
.floor.c0 { --tile: #16307a; }
.floor.c1 { --tile: #0b6a72; }
.floor.c2 { --tile: #e0a32e; --on: var(--ink); --chev: var(--chev-dark); }
.floor.c3 { --tile: #8e3b22; }
.floor.c4 { --tile: #41296f; }
/* Frise de coins, comme des signes pressés dans l'émail */
.floor::before {
  content: ""; display: block; height: 10px; background: currentColor; opacity: 0.5;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='10'%3E%3Cpath d='M0 0h12L0 10z'/%3E%3C/svg%3E") repeat-x;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='10'%3E%3Cpath d='M0 0h12L0 10z'/%3E%3C/svg%3E") repeat-x;
}
.floor-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 2px 18px; padding: 8px 20px 0; }
.floor-head select { font: 400 1.35rem/1.2 var(--display); background-image: var(--chev); }
.floor-tools { display: flex; flex-wrap: wrap; gap: 0 12px; }
.floor-tools button { background: none; border: 0; padding: 2px 0; color: inherit; font-size: 0.86rem; opacity: 0.85; }
.floor-tools button:hover { opacity: 1; text-decoration: underline; text-underline-offset: 3px; }
.tools-toggle { display: none; background: none; border: 0; padding: 2px 0; color: inherit; font-size: 0.88rem; text-decoration: underline; text-underline-offset: 3px; }
.floor :focus-visible { outline-color: currentColor; }
.floor-out { padding: 6px 20px 16px; min-height: 3.2em; font: 400 1.22rem/1.45 var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.floor-out:empty::before { content: "En attente du texte."; opacity: 0.65; font-style: italic; }
.floor-out.thinking { opacity: 0.7; font-style: italic; }
.floor-more { margin: 0 20px; padding: 10px 0 16px; border-top: 1px solid currentColor; display: grid; gap: 10px; font-size: 0.95rem; }
.floor-more h4 { margin: 0 0 2px; font-size: 0.9rem; }
.floor-more ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.floor-more .t { display: block; font: 400 1.08rem/1.4 var(--text); overflow-wrap: anywhere; }
.floor-more .n { display: block; opacity: 0.8; font-size: 0.86rem; }
.floor-more dl { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 2px 16px; margin: 0; }
.floor-more dt { font-weight: 700; overflow-wrap: anywhere; }
.floor-more dd { margin: 0; opacity: 0.85; }
@media (prefers-reduced-motion: no-preference) {
  .floor.new { animation: settle 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
  @keyframes settle { from { transform: translateY(-26px); opacity: 0; } }
}

/* Tablette d'argile */
.base { width: 100%; background: var(--clay); box-shadow: 0 -1px 0 var(--ink); }
.base-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; padding: 14px 20px 0; }
.base-head > select { font: 400 1.5rem/1.2 var(--display); }
.detected { background: var(--gold); padding: 0 7px; font-size: 0.86rem; font-weight: 600; }
.tone-wrap { margin-left: auto; color: var(--ink-soft); display: inline-flex; gap: 6px; font-size: 0.95rem; }
.tone-wrap select { color: var(--ink); font-weight: 700; }
textarea {
  display: block; width: 100%; min-height: 170px; padding: 8px 20px 12px; border: 0; background: transparent; resize: vertical;
  font: 400 1.3rem/1.45 var(--text); overflow-wrap: anywhere;
}
textarea:focus { outline: none; }
textarea::placeholder { color: var(--ink-soft); }
.base.drop { background: var(--gold); }
.base-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; padding: 10px 20px 14px; border-top: 2px solid var(--clay-line); }
.tools { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 14px; font-size: 0.93rem; }
.tools button, .tools label { background: none; border: 0; padding: 0; font-weight: 600; }
.tools button:hover, .tools label:hover { text-decoration: underline; text-underline-offset: 3px; }
.count { color: var(--ink-soft); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.go-wrap { display: flex; gap: 10px; }
.go { background: var(--ink); color: var(--clay); border: 0; padding: 12px 34px; font: 400 1.2rem/1 var(--display); }
.go:hover:not(:disabled) { background: #16307a; color: #fff; }
.go:disabled { opacity: 0.5; cursor: default; }
.stop { background: none; border: 2px solid var(--ink); padding: 8px 18px; font-weight: 700; }
.status { margin: 0; padding: 0 20px 12px; font-size: 0.95rem; }
.status:empty { display: none; }
.status.err { color: var(--error); font-weight: 600; }
.access { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 0 20px 16px; }
.access input { flex: 1 1 180px; min-width: 0; padding: 9px 10px; border: 2px solid var(--ink); background: #fff8ea; }

/* Terre */
.ground { color: var(--sand); padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); }
.band {
  max-width: 1180px; margin: 0 auto; padding-block: 38px 8px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.band h2 { margin: 0; font: 400 2rem/1.1 var(--display); }
.band-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 24px; }
.plain { background: none; border: 0; padding: 0; color: var(--sand-soft); font-size: 0.92rem; }
.plain:hover { color: var(--sand); text-decoration: underline; }
.ground :focus-visible { outline-color: var(--gold); }
.note { margin: 6px 0 0; color: var(--sand-soft); }

.tablets { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 16px; }
.tablet { display: grid; gap: 3px; text-align: left; min-width: 0; background: var(--clay); color: var(--ink); border: 0; padding: 12px 14px; }
.tablet:hover { background: var(--gold); }
.tablet span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tablet .pair { color: var(--ink-soft); font-size: 0.78rem; font-weight: 600; }
.tablet .s { font: 400 1.05rem/1.3 var(--text); }
.tablets .none { margin: 0; color: var(--sand-soft); }

.band-head input { flex: 0 1 280px; min-width: 0; padding: 8px 10px; border: 1px solid var(--earth-line); background: var(--earth-2); color: var(--sand); }
.band-head input::placeholder { color: var(--sand-soft); }
.lang-index { columns: 5 180px; column-gap: 26px; margin-top: 18px; }
.letter { break-inside: avoid; padding-bottom: 14px; }
.letter b { display: block; font: 400 1.5rem/1.2 var(--display); color: var(--gold); }
.letter button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 1px 0; color: var(--sand); font-size: 0.95rem; }
.letter button:hover { color: var(--gold); }
.letter button[aria-current="true"] { background: var(--gold); color: var(--ink); font-weight: 700; padding-inline: 4px; }
.no-match { margin: 0; color: var(--sand-soft); }

.help { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px 28px; margin-top: 16px; }
.help h3 { margin: 0 0 4px; font-size: 1rem; color: var(--gold); }
.help p { margin: 0; color: var(--sand-soft); font-size: 0.96rem; }

@media (max-width: 900px) {
  :root { --step: 22px; }
  .help { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  :root { --step: 9px; }
  .sky { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
  .sun { width: 190px; height: 190px; top: -60px; right: -30px; }
  .top nav { gap: 12px; font-size: 0.92rem; }
  .floor-head, .floor-out { padding-inline: 14px; }
  .tools-toggle { display: inline; }
  .floor-tools { display: none; flex-basis: 100%; }
  .floor.open .floor-tools { display: flex; }
  .floor-more { margin-inline: 14px; }
  .base-head, .base-foot { padding-inline: 14px; }
  textarea { padding-inline: 14px; font-size: 1.15rem; min-height: 150px; }
  .status { padding-inline: 14px; }
  .go-wrap, .go { flex: 1; }
  .help { grid-template-columns: minmax(0, 1fr); }
  .lang-index { columns: 2; column-gap: 16px; }
}
