/* Subtext - low-fi mockup styles. Tokens trace to design/ux.md and spec sec 8. */

:root {
  --paper: #f6f2e9;      /* warm off-white, cuts glare (BDA) */
  --surface: #fffdf8;    /* card */
  --ink: #23262b;        /* body text, ~11:1 on paper */
  --ink-soft: #555c68;   /* secondary, ~4.7:1 */
  --accent: #146860;     /* deep teal - primary, focus */
  --accent-ink: #0c433d; /* darker teal for text on paper */
  --mark: #ffdf7e;       /* highlighter yellow - signature, decorative */
  --mark-soft: #fff0c2;
  --line: #ddd5c5;       /* borders, >=3:1 non-text */
  --focus: #0b4f8a;      /* focus ring */
  --danger-ink: #7a3510; /* error heading ink, decorative + text */

  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;

  --measure: 66ch;
  --radius: 12px;
  --space: 8px;
}

:root[data-font="system"] {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-contrast="high"] {
  --paper: #ffffff;
  --surface: #ffffff;
  --ink: #000000;
  --ink-soft: #1a1a1a;
  --accent: #0a4a44;
  --accent-ink: #063a35;
  --line: #000000;
  --focus: #0033aa;
}

* { box-sizing: border-box; }

/* theme swap: suppress transitions for one frame so colours change instantly */
:root.no-transitions *, :root.no-transitions *::before, :root.no-transitions *::after {
  transition: none !important;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;      /* >=16px */
  line-height: 1.5;
  text-align: left;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 8px 14px;
  border-radius: 0 0 8px 0;
  z-index: 10;
}
.skip-link:focus { left: 0; }

/* --- focus visible everywhere --- */
a:focus-visible,
button:focus-visible,
textarea:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* --- header --- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 20px;
  padding: 28px 0 18px;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 2.4rem;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1;
  color: var(--ink);
}
.tagline {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.15rem;
  color: var(--accent-ink);
  margin: 0;
}
.im-badge {
  margin-left: auto;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  align-self: center;
}

/* --- mode toggle (segmented radio) --- */
.mode {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  padding: 3px;
  margin: 20px 0 0;
  width: max-content;
}
.mode legend {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
}
.mode label {
  position: relative;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  color: var(--accent-ink);
  min-height: 24px;
  display: inline-flex;
  align-items: center;
}
.mode input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.mode input:checked + span { background: var(--accent); color: #fff; }
.mode span {
  padding: 8px 18px;
  border-radius: 999px;
  display: inline-block;
  margin: -8px -18px;
}
.mode input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* --- display settings (real user controls) --- */
.display-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 14px 0 0;
  padding: 0;
  border: none;
  font-size: 0.9rem;
}
.display-settings legend {
  padding: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  font-weight: 700;
}
.display-settings label { display: inline-flex; align-items: center; gap: 6px; }
.display-settings select {
  font: inherit;
  font-size: 0.9rem;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  min-height: 24px;
}

.charcount { font-size: 0.85rem; color: var(--ink-soft); margin: 6px 0 0; }
.charcount.over { color: var(--danger-ink); font-weight: 700; }

/* --- example chips --- */
.chips { margin: 22px 0 8px; }
.chips-label { font-weight: 700; color: var(--ink-soft); margin-right: 8px; font-size: 0.95rem; }
.chip {
  font: inherit;
  font-size: 0.95rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  margin: 4px 6px 4px 0;
  cursor: pointer;
  color: var(--accent-ink);
  min-height: 24px;
}
.chip:hover { border-color: var(--accent); box-shadow: inset 0 -2px 0 var(--mark); }

/* --- two columns --- */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin: 8px 0 40px;
  align-items: start;
}
.col h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.15rem;
  margin: 0 0 10px;
  color: var(--ink);
}
.col .sub { font-size: 0.85rem; color: var(--ink-soft); font-weight: 400; }

label.field-label { display: block; font-weight: 700; margin-bottom: 6px; }

textarea {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  font: inherit;
  line-height: 1.5;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
textarea:focus { border-color: var(--accent); }

.btn {
  font: inherit;
  font-weight: 700;
  margin-top: 12px;
  padding: 11px 22px;
  min-height: 44px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.btn:hover { background: var(--accent-ink); }

/* --- result region + card --- */
.result {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  min-height: 240px;
}

.card { max-width: var(--measure); }

/* screen-reader only */
.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;
}

/* inline annotation of the original message (decode) */
.annotated { padding: 0 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.annotated-text { margin: 4px 0 12px; line-height: 1.8; }
.anno { padding: 1px 2px; border-radius: 3px; }
.anno-hedge { background: var(--mark-soft); border-bottom: 2px solid #c99a24; }
.anno-action { background: rgba(20, 104, 96, 0.12); border-bottom: 2px solid var(--accent); font-weight: 700; }
.anno-ambiguity { border-bottom: 2px dotted var(--danger-ink); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; font-size: 0.82rem; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); }
.legend-item::before { content: ""; width: 16px; height: 10px; border-radius: 2px; display: inline-block; }
.legend-hedge::before { background: var(--mark-soft); border-bottom: 2px solid #c99a24; }
.legend-action::before { background: rgba(20, 104, 96, 0.12); border-bottom: 2px solid var(--accent); }
.legend-ambiguity::before { border-bottom: 2px dotted var(--danger-ink); }
:root[data-contrast="high"] .anno-hedge { background: #fff2c2; border-bottom-color: #000; }
:root[data-contrast="high"] .anno-action { background: #d8ece9; border-bottom-color: #000; }
:root[data-contrast="high"] .anno-ambiguity { border-bottom-color: #000; }

.reveal { animation: fade 160ms ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.field { padding: 12px 0; border-top: 1px solid var(--line); }
.field:first-child { border-top: none; padding-top: 0; }
.field-name {
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-ink);
  margin: 0 0 3px;
}
.field-value { margin: 0; }

/* highlighter signature on the plain meaning */
.mark {
  background: linear-gradient(transparent 58%, var(--mark) 58%);
  padding: 0 1px;
}
.reveal .mark {
  background-size: 0% 100%;
  background-repeat: no-repeat;
  background-image: linear-gradient(var(--mark), var(--mark));
  animation: swipe 480ms 120ms ease-out forwards;
  box-shadow: none;
}
@keyframes swipe { to { background-size: 100% 100%; } }

.amb-list, .changed-list { margin: 4px 0 0; padding-left: 1.1em; }
.amb-list li, .changed-list li { margin: 4px 0; }

/* subtext block */
.subtext {
  margin-top: 6px;
  padding: 12px 14px;
  background: var(--mark-soft);
  border-radius: 10px;
  border: 1px solid #e6d79b;
}
.subtext .tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--danger-ink);
  border: 1px solid #e2c98f;
  border-radius: 6px;
  padding: 1px 7px;
  margin-bottom: 6px;
}
.confidence { font-weight: 700; }
.check { margin: 6px 0 0; }
.check b { color: var(--accent-ink); }

/* translate versions */
.version { padding: 12px 0; border-top: 1px solid var(--line); }
.version:first-of-type { border-top: none; }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 6px;
  padding: 2px 8px;
  margin-bottom: 6px;
}
.badge.start { background: var(--accent); color: #fff; }
.badge.diplo { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.register {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.register .bar { height: 8px; border-radius: 999px; background: var(--line); position: relative; margin-top: 6px; }
.register .bar i { position: absolute; top: -3px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); }
.register .ends { display: flex; justify-content: space-between; margin-top: 6px; }

/* empty / loading / refusal / error */
.statebox { max-width: var(--measure); }
.statebox h3 { font-family: var(--display); font-weight: 600; margin: 0 0 6px; font-size: 1.1rem; }
.statebox.muted { color: var(--ink-soft); }
.statebox.error h3 { color: var(--danger-ink); }
.loading-line { font-weight: 700; color: var(--accent-ink); }
.loading-dots { animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.loading-sub { color: var(--ink-soft); font-size: 0.92rem; margin: 2px 0 16px; }

/* loading skeleton (shape of the coming card; shimmer gated by reduced-motion) */
.skel { background: var(--line); border-radius: 6px; margin: 9px 0; position: relative; overflow: hidden; }
.skel-label { height: 10px; width: 34%; opacity: 0.75; margin-top: 16px; }
.skel-line { height: 15px; width: 100%; }
.skel-line.short { width: 68%; }
.skeleton .skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.65), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* --- footer --- */
.site-footer { border-top: 1px solid var(--line); padding: 22px 0 60px; margin-top: 20px; }
.evidence { max-width: var(--measure); margin-bottom: 16px; }
.evidence summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent-ink);
  padding: 6px 0;
  min-height: 24px;
}
.evidence[open] summary { margin-bottom: 6px; }
.evidence p { margin: 6px 0; }
.evidence-list { margin: 8px 0; padding-left: 1.1em; max-width: var(--measure); }
.evidence-list li { margin: 8px 0; }
.evidence a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.evidence a:hover { color: var(--accent); }
.notice { color: var(--ink-soft); font-size: 0.92rem; max-width: var(--measure); }
.notice strong { color: var(--ink); }

/* --- responsive: stack under 700px --- */
@media (max-width: 700px) {
  .columns { grid-template-columns: 1fr; gap: 20px; }
  .wordmark { font-size: 2rem; }
  .im-badge { margin-left: 0; }
}

/* --- interaction motion (purposeful, restrained; all disabled under reduced-motion) --- */
.btn {
  transition: background-color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(20, 104, 96, 0.24); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 3px rgba(20, 104, 96, 0.22); }

.chip {
  transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.12s ease;
}
.chip:hover { transform: translateY(-1px); }
.chip:active { transform: translateY(0) scale(0.98); }

.mode span { transition: background-color 0.2s ease, color 0.2s ease, transform 0.12s ease; }
.mode label:active span { transform: scale(0.97); }

.display-settings select { transition: border-color 0.16s ease, box-shadow 0.16s ease; }
.display-settings select:hover { border-color: var(--accent); }

textarea { transition: border-color 0.18s ease, box-shadow 0.18s ease; }
textarea:focus { box-shadow: 0 0 0 3px rgba(20, 104, 96, 0.12); }

.evidence summary { transition: color 0.16s ease; }
.evidence summary:hover { color: var(--accent); }

/* --- reduced motion: no animation, no movement (colour feedback stays) --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal .mark { background-size: 100% 100%; }
  .btn:hover, .btn:active,
  .chip:hover, .chip:active,
  .mode label:active span { transform: none !important; }
  .btn:hover, .btn:active { box-shadow: none !important; }
}
