/* Saltwrack — shared stylesheet */

:root {
  --paper: #f3ecdc;
  --card: #f8f3e6;
  --ink: #1d2b2e;
  --ink-soft: #4d5d5e;
  --sea: #0f4c52;
  --rust: #b4532a;
  --line: #c9bb9a;
  --dot: rgba(29, 43, 46, 0.07);
  --foot-bg: #0f4c52;
  --foot-fg: #f3ecdc;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --measure: 66ch;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121c1e;
    --card: #182528;
    --ink: #ebe4d0;
    --ink-soft: #a9b5b0;
    --sea: #7cc0b8;
    --rust: #e58f60;
    --line: #34484a;
    --dot: rgba(235, 228, 208, 0.06);
    --foot-bg: #0b2a2d;
    --foot-fg: #ebe4d0;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--ink);
  font: 1.0625rem/1.65 var(--serif);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1 0 auto; }

/* Tide-gauge ruler in the margin */
@media (min-width: 900px) {
  body::before {
    content: "";
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 30px;
    border-right: 1px solid var(--line);
    background:
      repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px 12px) right top / 12px 100% no-repeat,
      repeating-linear-gradient(to bottom, var(--ink-soft) 0 2px, transparent 2px 60px) right top / 22px 100% no-repeat;
    pointer-events: none;
    z-index: 0;
  }
}

img, svg { max-width: 100%; }

a { color: var(--sea); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--rust); }

:focus-visible { outline: 3px solid var(--rust); outline-offset: 3px; }

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1rem;
  z-index: 10;
}
.skip:focus { left: 0; }

.wrap {
  position: relative;
  z-index: 1;
  max-width: 70rem;
  margin-inline: auto;
  padding-inline: 1.25rem;
}
@media (min-width: 900px) {
  .wrap { padding-inline: 4rem 2rem; }
}

/* Header */
.site-header {
  position: relative;
  z-index: 2;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-block: 0.9rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--ink); }
.brand img { border-radius: 8px; display: block; }

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
}
nav a {
  color: var(--ink);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-block: 0.3rem;
}
nav a:hover,
nav a[aria-current="page"] {
  text-decoration: underline wavy var(--rust);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 7px;
}

/* Typography */
h1, h2, h3 { line-height: 1.1; letter-spacing: -0.015em; margin: 0 0 0.6em; }
h1 { font-size: clamp(2.5rem, 6.4vw, 4.8rem); line-height: 1.02; letter-spacing: -0.03em; }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.15rem); }
h3 { font-size: 1.45rem; }
em { color: var(--rust); font-style: italic; }
p { margin: 0 0 1.1em; }

.eyebrow, .kicker, .num, .date, .tag {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.9rem;
}
.kicker { color: var(--rust); }

.lede { font-size: 1.28rem; line-height: 1.55; max-width: 38em; color: var(--ink-soft); }

.fine { font-size: 0.88rem; color: var(--ink-soft); margin: 1rem 0 0; }

.prose { max-width: calc(var(--measure) + 8rem); }
.prose p { max-width: var(--measure); }

.section { padding-block: 2.5rem; }
.page-head { padding-block: 3.5rem 1rem; }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-top: 1.75rem; }
.btn {
  display: inline-block;
  padding: 0.75rem 1.3rem;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  box-shadow: 4px 4px 0 var(--rust);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { color: var(--paper); transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--rust); }
.btn.alt { background: transparent; color: var(--ink); }
.btn.alt:hover { color: var(--ink); }

/* Home hero */
.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 3rem;
  align-items: center;
  padding-block: 4rem 2.5rem;
}
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-block: 2.5rem 1.5rem; gap: 2.5rem; }
}

/* Tide card */
.tide-card {
  background: var(--card);
  border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 var(--sea);
  padding: 1.4rem 1.4rem 1.2rem;
}
.tide-card h2 { font-size: 1.5rem; margin-bottom: 0.4rem; }
.tide-svg { display: block; width: 100%; height: auto; }
.tide-rule { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.tide-area { fill: var(--sea); opacity: 0.14; }
.tide-curve { fill: none; stroke: var(--sea); stroke-width: 2.5; stroke-linejoin: round; }
.tide-now-line, .tide-now-dot { display: none; }
.tide-card.is-live .tide-now-line {
  display: inline;
  stroke: var(--rust);
  stroke-width: 1.2;
  stroke-dasharray: 2 3;
}
.tide-card.is-live .tide-now-dot {
  display: inline;
  fill: var(--rust);
  stroke: var(--card);
  stroke-width: 2;
}
.axis { font: 10px var(--mono); fill: var(--ink-soft); }

.readout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 0.8rem 0 0;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}
.readout dt {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.readout dd { margin: 0.15rem 0 0; font-size: 1.02rem; font-weight: 700; line-height: 1.25; }

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.75rem;
  margin-top: 1rem;
}
.card {
  position: relative;
  background: var(--card);
  border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 var(--line);
  padding: 1.4rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translate(3px, 3px); box-shadow: 3px 3px 0 var(--rust); }
.card h3 { margin-bottom: 0.5rem; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; }
.card p:last-child { margin-bottom: 0; }
.num { color: var(--rust); margin-bottom: 0.5rem; }

/* Pull quote */
.pull {
  margin: 0;
  padding: 0.5rem 0 0.5rem 1.75rem;
  border-left: 5px solid var(--rust);
  max-width: 44rem;
}
.pull p { font-size: clamp(1.5rem, 3.4vw, 2.3rem); font-style: italic; line-height: 1.25; letter-spacing: -0.01em; }
.pull footer { font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.06em; color: var(--ink-soft); }

/* Table */
.table-wrap { overflow-x: auto; border: 2px solid var(--ink); background: var(--card); }
table { width: 100%; border-collapse: collapse; min-width: 36rem; }
caption {
  text-align: left;
  padding: 0.75rem 1rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--ink);
}
th, td { text-align: left; padding: 0.7rem 1rem; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 0;
}
tbody th { font-weight: 700; white-space: nowrap; color: var(--sea); }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--dot); }

/* Glossary */
.glossary {
  margin: 1rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1.25rem 2.5rem;
}
.glossary div { border-top: 2px solid var(--ink); padding-top: 0.7rem; }
.glossary dt { font-size: 1.2rem; font-weight: 700; color: var(--sea); }
.glossary dd { margin: 0.25rem 0 0; }

/* Notes */
.entries { padding-block: 1.5rem 3rem; }
.entry {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  gap: 1.5rem 2rem;
  border-top: 2px solid var(--ink);
  padding-block: 2rem;
}
.entry .date { color: var(--ink); font-size: 0.9rem; margin-bottom: 0.3rem; }
.entry .tag { color: var(--rust); }
.entry h2 { margin-bottom: 0.7em; }
.entry .body { max-width: var(--measure); }
.entry .body > p:first-of-type::first-letter {
  float: left;
  font-size: 3.6em;
  line-height: 0.8;
  padding: 0.08em 0.1em 0 0;
  color: var(--rust);
  font-weight: 700;
}
@media (max-width: 700px) {
  .entry { grid-template-columns: 1fr; gap: 0.5rem; }
}

/* 404 */
.lost { padding-block: 5rem 4rem; }

/* Footer with drifting wave */
.wave {
  height: 12px;
  margin-top: 3rem;
  background-color: var(--foot-bg);
  -webkit-mask-image: url("/assets/wave.svg");
  mask-image: url("/assets/wave.svg");
  -webkit-mask-repeat: repeat-x;
  mask-repeat: repeat-x;
  -webkit-mask-size: 80px 12px;
  mask-size: 80px 12px;
  animation: drift 6s linear infinite;
}
@keyframes drift {
  from { -webkit-mask-position: 0 0; mask-position: 0 0; }
  to { -webkit-mask-position: 80px 0; mask-position: 80px 0; }
}

.site-footer { background: var(--foot-bg); color: var(--foot-fg); padding-block: 1.75rem 2.25rem; position: relative; z-index: 1; }
.foot { display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; justify-content: space-between; align-items: center; }
.foot p { margin: 0; }
.foot ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 1.25rem; flex-wrap: wrap; }
.site-footer a {
  color: var(--foot-fg);
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.site-footer a:hover { color: var(--rust); }

@media (prefers-reduced-motion: reduce) {
  .wave { animation: none; }
  .btn, .card { transition: none; }
}