/* ============================================================
   RézoTrophix — style.css
   Identité visuelle : carnet de terrain / guide naturaliste.
   ============================================================ */

/* ------------------------------------------------------------
   Polices internalisées (aucune requête vers Google Fonts).
   Fichiers dans /fonts, sous licence SIL Open Font License 1.1
   (voir les fichiers OFL-*.txt du dossier fonts/).
------------------------------------------------------------ */
@font-face {
  font-family: "Work Sans";
  src: url("fonts/WorkSans-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Fraunces";
  src: url("fonts/Fraunces-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Uncial Antiqua";
  src: url("fonts/UncialAntiqua-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f4efe1;
  --paper-deep: #ece3cd;
  --ink: #22301f;
  --ink-soft: #4b5a43;
  --forest-deep: #1e3b2c;
  --forest: #3f6b4a;
  --moss: #7a9b6e;
  --amber: #d8973c;
  --amber-deep: #b97a26;
  --bark: #6b4a34;
  --sky: #6e97a6;
  --success: #4f7942;
  --danger: #b5473a;
  --line: rgba(34, 48, 31, 0.16);

  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", serif;
  --font-body: "Work Sans", "Segoe UI", system-ui, sans-serif;
  --font-brand: "Uncial Antiqua", "Fraunces", "Papyrus", serif;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow-soft: 0 6px 20px rgba(30, 59, 44, 0.12);
  --shadow-lift: 0 10px 28px rgba(30, 59, 44, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(circle at 15% 10%, rgba(122, 155, 110, 0.14), transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(216, 151, 60, 0.1), transparent 45%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--forest-deep);
  margin: 0;
}

a {
  color: inherit;
}

/* ---------------------------------------------------------
   Bandeau d'en-tête
--------------------------------------------------------- */
.rtx-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: linear-gradient(180deg, var(--forest-deep), #16291d);
  color: #f4efe1;
  box-shadow: var(--shadow-soft);
  z-index: 5;
}

.rtx-logo {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(216, 151, 60, 0.5);
}

.rtx-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.rtx-logo svg {
  width: 34px;
  height: 34px;
}

.rtx-title {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.rtx-title .brand {
  font-family: var(--font-brand);
  font-weight: 400;
  font-style: normal;
  font-size: 1.6rem;
  letter-spacing: 0.5px;
  color: #fdf8ec;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.rtx-title .tagline {
  font-size: 0.82rem;
  color: #cfe0cf;
  font-weight: 400;
}

.rtx-header-spacer {
  flex: 1;
}

.rtx-header-nav {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.85rem;
}

.rtx-header-nav a {
  text-decoration: none;
  color: #e6ead9;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(244, 239, 225, 0.35);
  transition: background 0.15s ease, color 0.15s ease;
}

.rtx-header-nav a:hover {
  background: rgba(244, 239, 225, 0.16);
}

/* ---------------------------------------------------------
   Boutons
--------------------------------------------------------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--amber);
  color: #2a1c0c;
  box-shadow: var(--shadow-soft);
}

.btn-primary:not(:disabled):hover {
  background: var(--amber-deep);
}

.btn-forest {
  background: var(--forest);
  color: #f4efe1;
  box-shadow: var(--shadow-soft);
}

.btn-forest:not(:disabled):hover {
  background: var(--forest-deep);
}

.btn-ghost {
  background: transparent;
  color: var(--forest-deep);
  border: 1.5px solid var(--line);
}

.btn-ghost:not(:disabled):hover {
  background: rgba(63, 107, 74, 0.08);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid rgba(181, 71, 58, 0.4);
}

.btn-danger-ghost:not(:disabled):hover {
  background: rgba(181, 71, 58, 0.08);
}

.btn.is-active {
  background: var(--forest-deep);
  color: #fff;
  box-shadow: inset 0 0 0 2px var(--amber);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
}

/* ---------------------------------------------------------
   Cartes / panneaux généraux
--------------------------------------------------------- */
.panel {
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.field-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
}

textarea, input[type="text"], select {
  font-family: var(--font-body);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.92rem;
  background: #fffdf7;
  color: var(--ink);
  width: 100%;
}

textarea:focus, input[type="text"]:focus, select:focus, button:focus-visible, .token:focus-visible {
  outline: 3px solid rgba(110, 151, 166, 0.55);
  outline-offset: 2px;
}

/* =========================================================
   PAGE ÉLÈVE — écran de chargement
========================================================= */
.load-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.load-card {
  max-width: 620px;
  width: 100%;
  padding: 44px 40px;
  text-align: center;
  position: relative;
}

.load-card .rtx-webmark {
  width: 130px;
  height: 130px;
  margin: 0 auto 22px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.load-card .rtx-webmark .webmark-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.load-card h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.load-card p.hint {
  color: var(--ink-soft);
  margin: 0 0 26px;
  font-size: 0.95rem;
}

.dropzone {
  border: 2px dashed var(--moss);
  border-radius: var(--radius);
  padding: 30px 20px;
  cursor: pointer;
  background: rgba(122, 155, 110, 0.08);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.dropzone.is-dragover {
  background: rgba(216, 151, 60, 0.14);
  border-color: var(--amber);
}

.dropzone .dz-icon {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 6px;
}

.dropzone .dz-text {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.dropzone .dz-text strong {
  color: var(--forest-deep);
}

.load-error {
  margin-top: 16px;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 600;
  min-height: 1.2em;
}

/* =========================================================
   PAGE ÉLÈVE — écran de traçage
========================================================= */
.work-screen {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 250px;
  flex: none;
  background: #fbf7ec;
  border-right: 1px dashed var(--line);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

.sidebar h3 {
  font-size: 0.95rem;
  font-family: var(--font-body);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--forest);
  margin-bottom: 8px;
}

.species-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.species-chip {
  border: none;
  border-radius: 999px;
  padding: 9px 14px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(34, 48, 31, 0.15);
  transition: transform 0.1s ease, opacity 0.15s ease;
  color: #2a2a1f;
}

.species-chip:hover {
  transform: translateY(-1px);
}

.species-chip.is-placed {
  opacity: 0.35;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.legend-hint {
  font-size: 0.82rem;
  color: var(--ink-soft);
  background: rgba(110, 151, 166, 0.12);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.4;
}

.legend-hint b {
  color: var(--forest-deep);
}

.mode-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mode-group .btn {
  justify-content: flex-start;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-box {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: rgba(63, 107, 74, 0.1);
  font-size: 0.88rem;
  color: var(--forest-deep);
  font-weight: 600;
  min-height: 1em;
  display: none;
}

.score-box.visible {
  display: block;
}

.score-box.score-ok {
  background: rgba(79, 121, 66, 0.16);
  color: var(--success);
}

.score-box.score-partial {
  background: rgba(216, 151, 60, 0.18);
  color: var(--amber-deep);
}

/* --- Zone de travail (SVG) --- */
.canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #f2ecdd;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.canvas-wrap.mode-link { cursor: crosshair; }
.canvas-wrap.mode-delete-link { cursor: not-allowed; }

#workSvg {
  display: block;
  width: 100%;
  height: 100%;
  background-color: #f2ecdd;
  touch-action: none;
}

.token-rect {
  stroke: rgba(34, 48, 31, 0.35);
  stroke-width: 1.2;
  filter: drop-shadow(0 2px 3px rgba(34, 48, 31, 0.25));
}

.token-text {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 18px;
  fill: #26301c;
  pointer-events: none;
  user-select: none;
}

.token-group {
  cursor: grab;
  touch-action: none;
}

.token-group.is-selected .token-rect {
  stroke: var(--amber-deep);
  stroke-width: 3;
}

.token-group.is-dragging {
  cursor: grabbing;
}

.token-delete {
  cursor: pointer;
  touch-action: none;
}

.token-delete circle {
  fill: #fff;
  stroke: var(--danger);
  stroke-width: 1.4;
}

.token-delete text {
  fill: var(--danger);
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
}

.link-path {
  fill: none;
  stroke: var(--bark);
  stroke-width: 2.6;
  marker-end: url(#arrowNeutral);
  cursor: pointer;
}

.link-path.link-hit {
  stroke: transparent;
  stroke-width: 18;
  cursor: pointer;
}

.link-path.link-correct {
  stroke: var(--success);
  marker-end: url(#arrowCorrect);
}

.link-path.link-incorrect {
  stroke: var(--danger);
  marker-end: url(#arrowIncorrect);
}

.export-header-name,
.export-header-meta {
  font-family: var(--font-body);
  fill: var(--ink);
}

/* =========================================================
   Boîte de dialogue export (nom/prénom)
========================================================= */
.rtx-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 40, 25, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.rtx-modal-backdrop.visible {
  display: flex;
}

.rtx-modal {
  background: #fffdf7;
  border-radius: var(--radius);
  padding: 28px 30px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lift);
}

.rtx-modal h3 {
  margin-bottom: 4px;
}

.rtx-modal p {
  color: var(--ink-soft);
  font-size: 0.88rem;
  margin: 0 0 16px;
}

.rtx-modal .field {
  margin-bottom: 14px;
}

.rtx-modal .privacy-note {
  margin: 16px 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--ink-soft);
  background: rgba(122, 155, 110, 0.12);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}

.rtx-modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* =========================================================
   PAGE PROFESSEUR
========================================================= */
.prof-main {
  flex: 1;
  padding: 28px 5vw 60px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 24px;
  align-items: start;
}

@media (max-width: 980px) {
  .prof-main {
    grid-template-columns: 1fr;
  }
}

.card {
  padding: 22px 24px;
  margin-bottom: 22px;
}

.card h2 {
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.card .card-sub {
  color: var(--ink-soft);
  font-size: 0.86rem;
  margin-bottom: 16px;
}

.upload-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.file-input-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.divider-or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin: 14px 0;
}

.divider-or::before,
.divider-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.radio-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.radio-card {
  flex: 1;
  min-width: 200px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.radio-card:hover {
  border-color: var(--moss);
}

.radio-card.is-checked {
  border-color: var(--forest);
  background: rgba(63, 107, 74, 0.08);
}

.radio-card input {
  margin-top: 3px;
}

.radio-card .rc-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--forest-deep);
  display: block;
}

.radio-card .rc-desc {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

table.matrix-preview {
  border-collapse: collapse;
  font-size: 0.78rem;
  width: 100%;
  overflow-x: auto;
  display: block;
}

table.matrix-preview th, table.matrix-preview td {
  border: 1px solid var(--line);
  padding: 5px 8px;
  text-align: center;
  white-space: nowrap;
}

table.matrix-preview th {
  background: rgba(63, 107, 74, 0.1);
  color: var(--forest-deep);
}

table.matrix-preview td.cell-yes {
  background: rgba(216, 151, 60, 0.22);
  font-weight: 700;
  color: var(--amber-deep);
}

.chip-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip-preview {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  color: #2a2a1f;
}

.status-line {
  font-size: 0.85rem;
  margin-top: 10px;
  min-height: 1.3em;
}

.status-line.ok { color: var(--success); font-weight: 600; }
.status-line.error { color: var(--danger); font-weight: 600; }

.summary-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-list li {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 6px;
}

.summary-list b { color: var(--forest-deep); }

footer.rtx-footer {
  flex: none;
  text-align: center;
  font-size: 0.72rem;
  color: var(--ink-soft);
  padding: 8px 14px;
  opacity: 0.75;
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.02);
  border-top: 1px solid var(--line);
}

footer.rtx-footer a {
  color: var(--forest);
  text-decoration: none;
  font-weight: 600;
}

footer.rtx-footer a:hover {
  text-decoration: underline;
}

.brand-title {
  font-family: var(--font-brand);
  font-weight: 400;
  letter-spacing: 0.5px;
}

.rtx-footer-sep {
  opacity: 0.5;
}

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

@media (max-width: 720px) {
  .work-screen { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px dashed var(--line);
    max-height: 40vh;
  }
  .sidebar-footer { width: 100%; }
}
