/* Kajin Ṃajeḷ translator.

   The one thing this interface must never blur: what the corpus attests
   versus what a model guessed. That distinction is carried by colour, border
   and label, not by a footnote — a verified answer is a solid card with a
   source; a generated one is amber, dashed, and says so before you read it. */

:root {
  --deep:    #06202e;
  --ocean:   #0d3d52;
  --lagoon:  #17879c;
  --foam:    #e8f4f4;
  --sand:    #f6f1e7;
  --paper:   #fbfaf7;
  --ink:     #10242e;
  --muted:   #5b7382;
  --line:    #d9e3e6;
  --verified:#0f766e;
  --verified-bg:#e7f5f1;
  --sourced: #075985;
  --sourced-bg: #e0f2fe;
  --guess:   #a45a17;
  --guess-bg:#fdf3e4;
  --coral:   #d9563f;
  --serif: "Noto Serif", Georgia, "Iowan Old Style", serif;
  --sans: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow: 0 1px 2px rgba(6,32,46,.05), 0 12px 32px -12px rgba(6,32,46,.22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 88% -8%, rgba(23,135,156,.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(217,86,63,.07), transparent 60%),
    var(--paper);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--deep); color: white; padding: .75rem 1rem; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; top: 0; z-index: 50; }

/* --- the stick chart ---------------------------------------------------- */
.chart {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(38vw, 30rem);
  pointer-events: none; z-index: 0;
  /* Faded at the inner edge so it never competes with the text column. */
  -webkit-mask-image: linear-gradient(90deg, transparent, black 42%);
  mask-image: linear-gradient(90deg, transparent, black 42%);
}
.chart svg { width: 100%; height: 100%; display: block; }
.chart-lattice path {
  fill: none; stroke: var(--ocean); stroke-width: 1; opacity: .13;
  stroke-linecap: round;
}
.chart-atolls circle { fill: var(--coral); opacity: .26; }
@media (max-width: 900px) { .chart { display: none; } }

/* --- masthead ----------------------------------------------------------- */
.masthead {
  position: relative; z-index: 1;
  max-width: 62rem; margin: 0 auto; padding: clamp(3rem, 8vw, 6rem) 1.5rem 0;
}
.masthead-tools {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 46rem; margin-bottom: 1rem;
}
.eyebrow {
  font-size: .78rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--lagoon); font-weight: 600; margin: 0;
}
.install {
  border: 1px solid var(--line); border-radius: 999px; background: white;
  color: var(--ocean); cursor: pointer; font: inherit; font-size: .82rem;
  font-weight: 600; padding: .55rem .9rem; box-shadow: 0 1px 3px rgba(6,32,46,.08);
}
.install:hover { border-color: var(--lagoon); background: var(--foam); }
.install:focus-visible { outline: 3px solid rgba(23,135,156,.35); outline-offset: 2px; }
.install[hidden] { display: none; }
}
h1 {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  line-height: 1.02; letter-spacing: -.022em;
  margin: 0 0 1.1rem; color: var(--deep); font-weight: 400;
  max-width: 15ch;
}
h1 em { font-style: italic; color: var(--lagoon); }
.lede {
  font-size: clamp(1.02rem, 1.6vw, 1.18rem); line-height: 1.6;
  color: var(--muted); max-width: 46ch; margin: 0;
}

/* --- composer ----------------------------------------------------------- */
main {
  position: relative; z-index: 1;
  max-width: 62rem; margin: 0 auto; padding: clamp(2rem, 5vw, 3.5rem) 1.5rem 4rem;
  display: grid; gap: 1.5rem;
}
.compose {
  background: white; border: 1px solid var(--line); border-radius: 20px;
  padding: clamp(1.25rem, 3vw, 2rem); box-shadow: var(--shadow);
}
.direction {
  display: inline-flex; gap: .25rem; padding: .25rem;
  background: var(--foam); border-radius: 999px; margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.dir {
  border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: .92rem; font-weight: 500; color: var(--muted);
  padding: .6rem 1.1rem; border-radius: 999px; transition: background .15s, color .15s;
}
.dir:hover { color: var(--ocean); }
.dir.is-active { background: white; color: var(--deep); box-shadow: 0 1px 3px rgba(6,32,46,.14); }

.field-label {
  display: block; font-size: .82rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); margin-bottom: .6rem;
}
textarea {
  width: 100%; font-family: var(--sans); font-size: 1.28rem; line-height: 1.5;
  color: var(--ink); padding: 1rem 1.1rem; border: 1.5px solid var(--line);
  border-radius: 14px; background: var(--paper); resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus {
  outline: none; border-color: var(--lagoon);
  box-shadow: 0 0 0 4px rgba(23,135,156,.14);
}
textarea::placeholder { color: #9bb0ba; }

/* --- the Marshallese keys ----------------------------------------------- */
.keys { margin-top: 1.1rem; }
.keys-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .78rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: .6rem;
}
.shift {
  font: inherit; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase;
  border: 1px solid var(--line); background: white; color: var(--muted);
  padding: .35rem .7rem; border-radius: 8px; cursor: pointer;
}
.shift[aria-pressed="true"] {
  background: var(--deep); border-color: var(--deep); color: white;
}
.keys-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.key {
  font-family: var(--serif); font-size: 1.5rem; line-height: 1;
  min-width: 3.1rem; padding: .65rem .4rem;
  background: white; color: var(--deep);
  border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer;
  transition: transform .09s, border-color .12s, background .12s;
}
.key:hover { border-color: var(--lagoon); background: var(--foam); }
.key:active { transform: translateY(1px); }
.key:focus-visible { outline: 3px solid rgba(23,135,156,.4); outline-offset: 2px; }
.keys-note { font-size: .84rem; color: var(--muted); margin: .8rem 0 0; }
.keys-note b { font-family: var(--serif); font-size: 1.05rem; color: var(--deep); }

.go {
  margin-top: 1.4rem; width: 100%;
  font: inherit; font-size: 1rem; font-weight: 600; letter-spacing: .01em;
  color: white; background: var(--deep); border: 0; border-radius: 14px;
  padding: 1rem; cursor: pointer; transition: background .15s, transform .09s;
}
.go:hover { background: var(--ocean); }
.go:active { transform: translateY(1px); }
.go[disabled] { opacity: .55; cursor: progress; }

/* --- results ------------------------------------------------------------ */
.result { display: grid; gap: 1rem; }
.empty {
  border: 1.5px dashed var(--line); border-radius: 20px;
  padding: clamp(1.5rem, 4vw, 2.5rem); text-align: center; color: var(--muted);
}
.empty p { margin: 0 0 .5rem; font-size: 1.05rem; }
.empty-note { font-size: .9rem; max-width: 44ch; margin: 0 auto; line-height: 1.55; }

.card {
  background: white; border: 1px solid var(--line); border-left-width: 5px;
  border-radius: 16px; padding: clamp(1.25rem, 3vw, 1.75rem);
  box-shadow: var(--shadow);
}
.card.is-verified { border-left-color: var(--verified); }
.card.is-sourced { border-left-color: var(--sourced); }
.card.is-guess { border-left-color: var(--guess); border-style: dashed; border-left-style: solid; }
.card.is-empty { border-left-color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .74rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  padding: .38rem .7rem; border-radius: 999px; margin-bottom: 1rem;
}
.badge.is-verified { background: var(--verified-bg); color: var(--verified); }
.badge.is-sourced { background: var(--sourced-bg); color: var(--sourced); }
.badge.is-guess { background: var(--guess-bg); color: var(--guess); }
.badge.is-empty { background: #eef2f4; color: var(--muted); }
.badge .dot { width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }

.answer {
  font-family: var(--serif); font-size: clamp(1.7rem, 4.4vw, 2.5rem);
  line-height: 1.28; color: var(--deep); margin: 0 0 .9rem; word-break: break-word;
}
.notice { font-size: .93rem; line-height: 1.6; color: var(--muted); margin: 0; }
.source {
  margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--line);
  font-size: .86rem; color: var(--muted); display: flex; gap: .5rem; flex-wrap: wrap;
}
.source b { color: var(--ink); font-weight: 600; }
.ref {
  font-family: var(--serif); font-style: italic; color: var(--verified);
}

.alts { margin-top: 1.1rem; }
.alts h3 {
  font-size: .76rem; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 .7rem;
}
.alt {
  display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.3fr);
  gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--line);
  font-size: .95rem; align-items: baseline;
}
.alt .from { color: var(--muted); }
.alt .to { font-family: var(--serif); font-size: 1.1rem; color: var(--deep); }
.alt .prov { grid-column: 1 / -1; font-size: .78rem; color: #8fa3ad; }

footer {
  position: relative; z-index: 1;
  max-width: 62rem; margin: 0 auto; padding: 0 1.5rem 3rem;
  font-size: .8rem; line-height: 1.6; color: #8fa3ad;
}

@media (max-width: 640px) {
  .alt { grid-template-columns: 1fr; gap: .2rem; }
  .key { min-width: 2.8rem; font-size: 1.35rem; }
  .direction { width: 100%; }
  .dir { flex: 1; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
