/* Sjöklart — design tokens and components.
   The language: a nautical chart set like a good newspaper.
   Paper and ink first; colour only where it means something. */

:root {
  /* Paper & ink */
  --paper: #f4f0e6;
  --paper-2: #ebe5d6;
  --card: #fbfaf6;
  --ink: #0c2230;
  --ink-2: #3a4c57;
  --ink-3: #6d7b83;
  --hair: rgba(12, 34, 48, 0.14);
  --hair-2: rgba(12, 34, 48, 0.28);

  /* Sea — the hue of the game's Default water (src/water/appearance.ts),
     deepened so it holds 6:1 contrast as text on paper. */
  --sea: #2a6084;
  --sea-deep: #17354f;
  --shoal: #d5e3ec;
  --shoal-2: #bad0de;
  --land: #ecdcab;
  --land-edge: #b89a52;

  /* Signal — reserved for their nautical meaning */
  --port: #c7372f;
  --stbd: #1d7a4b;
  --mark: #f1b517;

  /* Night (for dark sections) */
  --night: #0c2230;
  --night-2: #143243;
  --night-hair: rgba(244, 240, 230, 0.16);

  /* Type */
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Schibsted Grotesk", system-ui, -apple-system, sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Space & shape */
  --gutter: clamp(16px, 4vw, 40px);
  --maxw: 1240px;
  --r-sm: 8px;
  --r: 14px;
  --r-lg: 22px;
  --shadow: 0 1px 0 rgba(12, 34, 48, 0.04), 0 12px 32px -12px rgba(12, 34, 48, 0.18);
  --shadow-lg: 0 2px 0 rgba(12, 34, 48, 0.04), 0 40px 80px -30px rgba(12, 34, 48, 0.35);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
[hidden] {
  display: none !important;
}
img,
svg {
  display: block;
  max-width: 100%;
}
a {
  color: inherit;
}
button {
  font: inherit;
  color: inherit;
}
::selection {
  background: var(--mark);
  color: var(--ink);
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Type ---------- */

.display,
.h1,
.h2,
.h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-variation-settings: "opsz" 144, "SOFT" 30;
  letter-spacing: -0.02em;
  line-height: 1.02;
  margin: 0;
  text-wrap: balance;
}
.display {
  font-size: clamp(48px, 8.2vw, 112px);
  letter-spacing: -0.035em;
  line-height: 0.95;
}
.h1 {
  font-size: clamp(40px, 5.6vw, 76px);
  letter-spacing: -0.03em;
}
.h2 {
  font-size: clamp(32px, 4vw, 54px);
}
.h3 {
  font-size: clamp(22px, 2.2vw, 28px);
  line-height: 1.12;
  letter-spacing: -0.012em;
  font-variation-settings: "opsz" 48, "SOFT" 30;
}
.display em,
.h1 em,
.h2 em,
.h3 em {
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100;
  color: var(--sea);
}
.lede {
  font-size: clamp(18px, 1.6vw, 21px);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 34em;
  margin: 0;
  text-wrap: pretty;
}
.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: currentColor;
}
.eyebrow.plain::before {
  display: none;
}
.mono {
  font-family: var(--mono);
  font-size: 0.86em;
  letter-spacing: 0.01em;
}
p {
  margin: 0;
}

/* ---------- Wordmark ----------
   "Sjöklart" in Fraunces. The diaeresis becomes the two sidelights:
   red to port, green to starboard. The real ö is laid over a plain o and
   clipped above the bowl, so the dots keep the typeface's own drawing.
   60.4% is where Fraunces' dots end and the bowl begins at line-height 1. */

.wordmark {
  font-family: var(--serif);
  font-weight: 500;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  letter-spacing: -0.03em;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  color: var(--ink);
  display: inline-block;
}
.wordmark .o {
  position: relative;
  display: inline-block;
  line-height: 1;
}
.wordmark .o::before,
.wordmark .o::after {
  content: "ö";
  position: absolute;
  inset: 0;
}
.wordmark .o::before {
  color: var(--port);
  clip-path: inset(0 50% var(--o-cut, 60.4%) 0);
}
.wordmark .o::after {
  color: var(--stbd);
  clip-path: inset(0 0 var(--o-cut, 60.4%) 50%);
}
.wordmark.mono-ink .o::before,
.wordmark.mono-ink .o::after {
  color: inherit;
}

/* ---------- Buttons ---------- */

.btn {
  --bg: var(--ink);
  --fg: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  padding: 0 24px;
  border-radius: 999px;
  border: 1px solid var(--bg);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s, box-shadow 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px -10px rgba(12, 34, 48, 0.5);
}
.btn:active {
  transform: translateY(0);
}
.btn:focus-visible,
.chip-btn:focus-visible,
.helm-btn:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--mark);
  outline-offset: 3px;
}
.btn.ghost {
  --bg: transparent;
  --fg: var(--ink);
  border-color: var(--hair-2);
}
.btn.ghost:hover {
  border-color: var(--ink);
  box-shadow: none;
}
.btn.sm {
  height: 40px;
  padding: 0 18px;
  font-size: 15px;
}
.btn.light {
  --bg: var(--paper);
  --fg: var(--ink);
}
.btn .arrow {
  transition: transform 0.2s var(--ease);
}
.btn:hover .arrow {
  transform: translateX(3px);
}

/* Helm buttons — the three decisions. Colour marks the side, not the verdict. */
.helm {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.helm-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 14px;
  border-radius: var(--r);
  border: 1px solid var(--hair-2);
  background: var(--card);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.15s var(--ease), background 0.15s;
}
.helm-btn:hover:not(:disabled) {
  border-color: var(--ink);
  transform: translateY(-1px);
}
.helm-btn:disabled {
  cursor: default;
  opacity: 0.5;
}
.helm-btn .k {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.helm-btn .k::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
}
.helm-btn.port .k::before {
  background: var(--port);
}
.helm-btn.stbd .k::before {
  background: var(--stbd);
}
.helm-btn .v {
  font-weight: 600;
  font-size: 15px;
}
.helm-btn.chosen {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  opacity: 1;
}
.helm-btn.chosen .k {
  color: rgba(244, 240, 230, 0.6);
}

/* ---------- Chips & tags ---------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--hair-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag.solid {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.tag.mark {
  background: var(--mark);
  color: var(--ink);
  border-color: var(--mark);
}
.tag.sea {
  background: var(--shoal);
  border-color: transparent;
  color: var(--sea-deep);
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

/* Rule card — the explanation that follows every encounter */
.rule-card {
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  padding: 20px 22px 18px;
  box-shadow: var(--shadow-lg);
}
.rule-card .ref {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sea);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.rule-card h4 {
  font-family: var(--serif);
  font-weight: 400;
  font-variation-settings: "opsz" 48, "SOFT" 30;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 8px 0 6px;
}
.rule-card p {
  font-size: 14.5px;
  color: var(--ink-2);
  line-height: 1.5;
}

/* Criteria — how an encounter is graded */
.criteria {
  list-style: none;
  margin: 0;
  padding: 0;
}
.criteria li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: start;
  gap: 10px;
  padding: 11px 0;
  border-top: 1px solid var(--hair);
  font-size: 15px;
}
.criteria li:first-child {
  border-top: 0;
}
.criteria .st {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  margin-top: 1px;
}
.criteria .pass .st {
  background: var(--stbd);
  color: #fff;
}
.criteria .partial .st {
  background: var(--mark);
  color: var(--ink);
}
.criteria .fail .st {
  background: var(--port);
  color: #fff;
}
.criteria .name {
  font-weight: 600;
}
.criteria .note {
  display: block;
  font-weight: 400;
  color: var(--ink-3);
  font-size: 13.5px;
  margin-top: 2px;
}
.criteria .val {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-3);
}

/* ---------- Neatline — the graduated border of a chart ---------- */

.neatline {
  --nl: 7px;
  --seg: 30px;
  --nlc: var(--ink);
  padding: var(--nl);
  border: 1px solid var(--nlc);
  background:
    repeating-linear-gradient(90deg, var(--nlc) 0 var(--seg), transparent 0 calc(var(--seg) * 2)) top / 100% var(--nl) no-repeat,
    repeating-linear-gradient(90deg, var(--nlc) 0 var(--seg), transparent 0 calc(var(--seg) * 2)) bottom / 100% var(--nl) no-repeat,
    repeating-linear-gradient(180deg, var(--nlc) 0 var(--seg), transparent 0 calc(var(--seg) * 2)) left / var(--nl) 100% no-repeat,
    repeating-linear-gradient(180deg, var(--nlc) 0 var(--seg), transparent 0 calc(var(--seg) * 2)) right / var(--nl) 100% no-repeat,
    var(--card);
}
.neatline > .inner {
  border: 1px solid var(--nlc);
  overflow: hidden;
  position: relative;
}

/* ---------- Inputs ---------- */

.field {
  display: flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--hair-2);
  max-width: 460px;
}
.field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0 14px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}
.field input::placeholder {
  color: var(--ink-3);
}
.field .btn {
  height: 44px;
}

/* ---------- Reveal ---------- */

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}
.reveal.in {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}
