/* Ett sjökort på bordet, i Kustkolls egen palett: papper, sjöblått och sandgult land, marinblå text,
   kort med tunn mässingskant som i appens menyer, och nattlägets rött på svart som egen sektion.
   Startsidan öppnar i skymningen, med en fyr och ett segelfartyg ritade i samma färger. */

@font-face {
  font-family: "Source Serif";
  src: url("/kustkoll/fonts/source-serif-4-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* Palette.day och Palette.night i Theme.swift. */
:root {
  --paper: #fffefa;
  --card: #fffdf5;
  --land: #f5e0a3;
  --land-edge: #9e8045;
  --shallow: #c2e0f0;
  --shallow-edge: #78adcc;
  --navy: #12294a;
  --navy-soft: #4d5e78;
  --brass: #b8913d;
  --brass-text: #805e17;
  --on-navy: #fcf5de;
  --right: #176f4a;
  --wrong: #a82b21;
  --night-deep: #080000;
  --night-card: #1a0403;
  --night-red: #f54533;
  --night-soft: #e2715f;
  --night-edge: #7a1c14;
  /* Skymningen i hero: en mörkare marinblå och en mässing som går att läsa på den. */
  --dusk: #0c1b33;
  --brass-light: #dcb866;
  --serif: "Source Serif", "New York", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--navy);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.55;
}

img, svg { display: block; max-width: 100%; }

a { color: var(--navy); text-underline-offset: 0.18em; text-decoration-color: var(--brass); }
a:hover { color: var(--brass-text); }
:focus-visible { outline: 3px solid var(--brass-text); outline-offset: 3px; border-radius: 4px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0; }
h2 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h3 { font-size: 1.2rem; }

.wrap { width: min(1120px, 100% - 40px); margin-inline: auto; }
.narrow { width: min(720px, 100% - 40px); }
.muted { color: var(--navy-soft); }
.skip-link { position: absolute; left: 12px; top: -80px; z-index: 20; padding: 8px 14px; background: var(--on-navy); color: var(--navy); font-weight: 700; border-radius: 8px; }
.skip-link:focus { top: 12px; }

.card {
  background: var(--card);
  border: 1px solid rgb(184 145 61 / 0.45);
  border-radius: 14px;
  box-shadow: 0 2px 5px rgb(18 41 74 / 0.08);
}

/* Header */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-block: 20px;
}
.brand { font-family: var(--serif); font-weight: 700; text-decoration: none; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.95rem; }

/* The landing page opens in the dusk, so its header sits on navy. */
.defs { position: absolute; }
.landing { background: linear-gradient(var(--dusk) 0, var(--dusk) 320px, var(--paper) 320px) no-repeat; }
.landing .site-header a { color: var(--on-navy); }
.landing .site-header a:hover { color: var(--brass-light); }
.landing .site-header :focus-visible { outline-color: var(--brass-light); }

/* Hero: the title over a lighthouse and a schooner at dusk. */
.hero {
  background: linear-gradient(var(--dusk) 0%, var(--navy) 42%, #1d4166 100%);
  color: var(--on-navy);
  overflow: hidden;
}
.hero-text { position: relative; z-index: 1; padding-top: 28px; }
.hero-icon { width: 88px; height: 88px; border-radius: 20px; border: 1px solid rgb(184 145 61 / 0.6); box-shadow: 0 8px 22px rgb(0 0 0 / 0.35); }
.hero h1 { font-size: clamp(3.5rem, 11vw, 6.5rem); margin-top: 18px; letter-spacing: -0.015em; line-height: 1; }
.byline { font-family: var(--serif); font-weight: 700; color: var(--brass-light); margin: 10px 0 0; font-size: 1.15rem; }
.pitch { font-size: clamp(1.2rem, 2.4vw, 1.45rem); line-height: 1.4; margin: 18px 0 0; max-width: 24em; }
.status {
  display: inline-block;
  margin: 26px 0 0;
  padding: 12px 22px;
  background: var(--on-navy);
  color: var(--navy);
  font-weight: 700;
  border: 1.5px solid var(--brass);
  border-radius: 12px;
}
/* Apples märke, oförändrat. */
.store-badge { display: block; width: fit-content; margin: 26px 0 0; border-radius: 9px; }
.store-badge img { display: block; }
.store-badge:focus-visible { outline-color: var(--brass-light); border-radius: 9px; }
.scene { width: 100%; height: clamp(330px, 41.7vw, 800px); margin: 8px 0 -1px; }
.shore { fill: var(--paper); }
.beam { transform-origin: 1010px 195px; animation: sweep 7s ease-in-out infinite alternate; }
.bob { transform-origin: 560px 441px; animation: bob 5s ease-in-out infinite alternate; }
.swell-a { animation: swell 6s ease-in-out infinite alternate; }
.swell-b { animation: swell 8s ease-in-out infinite alternate-reverse; }
@keyframes sweep { from { transform: scaleX(1); } to { transform: scaleX(-0.62); } }
@keyframes bob { from { transform: rotate(-1.2deg); } to { transform: rotate(1.2deg) translateY(3px); } }
@keyframes swell { from { transform: translateX(-30px); } to { transform: translateX(30px); } }

/* The game in numbers */
.facts ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  padding: 28px 0;
  border-bottom: 1px solid rgb(184 145 61 / 0.45);
}
.facts li { padding-inline: 20px; border-left: 1px solid rgb(184 145 61 / 0.45); color: var(--navy-soft); }
.facts li:first-child { padding-left: 0; border-left: 0; }
.facts b { display: block; font-family: var(--serif); font-size: clamp(2.2rem, 5vw, 3.25rem); line-height: 1.05; color: var(--navy); }

/* Sections */
.section { padding-block: 72px; }
.section h2::before {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  margin-bottom: 16px;
  border-radius: 2px;
  background: var(--brass);
}
.section-lead { margin: 12px 0 0; max-width: 38em; font-size: 1.15rem; }
.water { background: var(--shallow); border-block: 1px solid var(--shallow-edge); }
.water h2::before { background: var(--navy); }
.last { padding-bottom: 72px; }

/* How it works: four waypoints on a plotted course. */
.steps {
  position: relative;
  list-style: none;
  counter-reset: step;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 28px;
  padding: 0;
  margin: 36px 0 0;
}
.steps::before {
  content: "";
  position: absolute;
  top: 21px;
  left: 22px;
  right: 0;
  border-top: 2px dashed var(--brass);
}
.steps li { position: relative; counter-increment: step; }
.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--on-navy);
  border: 2px solid var(--brass);
  box-shadow: 0 0 0 6px var(--paper);
  font-family: var(--serif);
  font-weight: 700;
}
.steps p { margin: 6px 0 0; color: var(--navy-soft); }

/* The chart, framed like a sheet on the table. */
.chart-grid { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.6fr); gap: 48px; align-items: center; }
.rose { width: 132px; height: 132px; margin-bottom: 24px; color: var(--navy); }
.chart { margin: 0; padding: 10px; background: var(--card); border: 1px solid var(--brass); border-radius: 14px; box-shadow: 0 10px 26px rgb(18 41 74 / 0.18); }
.chart img { width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--navy-soft); }

/* Ta rodret: a playable course. The chart is a sheet of paper on navy, like the hero. */
.helm-section { background: linear-gradient(var(--dusk), var(--navy)); color: var(--on-navy); }
.helm-section h2::before { background: var(--brass-light); }
.helm-section a { color: var(--on-navy); }
.helm-head { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px 48px; align-items: end; }
.helm-keys { list-style: none; display: grid; gap: 6px; margin: 0; padding: 0; font-size: 0.95rem; color: rgb(252 245 222 / 0.82); }
.helm-keys b { display: inline-block; min-width: 3.6em; color: var(--brass-light); }
.helm { margin-top: 28px; }
.helm-stage {
  position: relative;
  height: clamp(440px, 64vh, 640px);
  overflow: hidden;
  background: var(--paper);
  color: var(--navy);
  border: 2px solid var(--brass);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.35);
  touch-action: pan-y;
}
.helm-stage:focus-visible { outline: 3px solid var(--brass-light); outline-offset: 4px; }
.helm-stage canvas { display: none; width: 100%; height: 100%; }
.helm-fallback { display: grid; grid-template-columns: auto minmax(0, 28ch); gap: 24px; align-items: center; justify-content: center; height: 100%; margin: 0; padding: 20px; }
.helm-fallback img { height: 100%; max-height: 400px; width: auto; border-radius: 14px; border: 1px solid var(--brass); }
.helm-hud, .helm-take, .helm-controls { display: none; }
.is-ready .helm-stage canvas { display: block; }
.is-ready .helm-fallback { display: none; }
.is-ready .helm-hud { position: absolute; inset: 10px 10px auto; display: grid; grid-template-columns: minmax(0, 230px) auto minmax(0, 230px); justify-content: center; gap: 8px; align-items: start; pointer-events: none; }
.helm-compass { width: clamp(76px, 12vw, 104px); height: auto; }
.helm-panel { margin: 0; padding: 8px 12px; background: rgb(255 253 245 / 0.92); border: 1px solid rgb(184 145 61 / 0.6); border-radius: 10px; font-size: 0.85rem; line-height: 1.3; }
.helm-panel b { display: block; font-size: 0.95rem; }
.helm-panel:last-child { text-align: right; }
.helm-toast {
  position: absolute;
  left: 50%;
  top: clamp(100px, 13vw + 30px, 128px);
  translate: -50% 0;
  width: max-content;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 8px 14px;
  background: var(--navy);
  color: var(--on-navy);
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
}
.helm-toast[data-kind="right"] { background: var(--right); }
.helm-toast[data-kind="wrong"] { background: var(--wrong); }
.is-ready .helm-take { display: block; position: absolute; left: 50%; bottom: 18px; translate: -50% 0; }
.helm-take, .helm-again {
  padding: 13px 26px;
  background: var(--navy);
  color: var(--on-navy);
  border: 2px solid var(--brass);
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgb(18 41 74 / 0.3);
}
.helm-take:hover, .helm-again:hover { background: #1d3c66; }
.helm-take[hidden] { display: none; }
.helm-result { position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: min(440px, 100% - 24px); max-height: calc(100% - 24px); overflow: auto; padding: 20px 22px; box-shadow: 0 16px 40px rgb(18 41 74 / 0.35); }
.helm-result[hidden] { display: none; }
.helm-result-kicker { margin: 0; color: var(--brass-text); font-size: 0.9rem; font-weight: 700; }
.helm-result h3 { margin-top: 2px; font-size: 1.35rem; }
.helm-stars { margin: 6px 0 0; color: #d9772b; font-size: 1.5rem; letter-spacing: 0.1em; line-height: 1; }
.helm-stars:empty { display: none; }
.helm-result ul { list-style: none; display: grid; gap: 4px; margin: 12px 0 0; padding: 0; font-size: 0.95rem; }
.helm-result li { padding-left: 1.5em; text-indent: -1.5em; }
.helm-result li::before { content: "○ "; color: var(--navy-soft); }
.helm-result li.is-passed::before { content: "● "; color: var(--right); }
.helm-remarks { margin: 10px 0 0; color: var(--wrong); font-size: 0.92rem; }
.helm-again { margin-top: 16px; width: 100%; }
.is-ready .helm-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.8fr); gap: 16px; margin-top: 14px; }
.helm:not(.is-player) .helm-controls { opacity: 0.45; pointer-events: none; }
.helm-controls label { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 14px; background: rgb(252 245 222 / 0.08); border: 1px solid rgb(220 184 102 / 0.45); border-radius: 12px; }
.helm-controls label > span:first-child { grid-column: 1 / -1; font-weight: 700; font-size: 0.9rem; color: var(--brass-light); }
.helm-gas input { grid-column: 1 / -1; }
.helm-side { font-size: 0.8rem; font-weight: 700; }
.helm-bb { color: #ff8f84; }
.helm-sb { color: #7fdf9f; }
.helm-controls input { width: 100%; height: 34px; margin: 0; accent-color: var(--brass-light); touch-action: none; }
.helm-note { margin: 12px 0 0; font-weight: 600; }
.helm:not(.is-ready) .helm-note { display: none; }
.helm-small { margin: 8px 0 0; max-width: 60em; font-size: 0.92rem; color: rgb(252 245 222 / 0.72); }

/* Sea marks: the two rules as pictures, then the six marks. */
.rules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 32px; }
.rule { padding: 24px; }
.rule h3 { font-size: 1.4rem; }
.rule > p { margin: 8px 0 0; color: var(--navy-soft); }
.rule-figure { width: 100%; height: auto; margin-top: 18px; border: 1px solid var(--shallow-edge); border-radius: 10px; }
.rule-figure text { font-family: var(--sans); fill: var(--navy); }
.rule-label text { font-size: 23px; font-weight: 700; }
.rule-label .rule-sub { font-size: 19px; font-weight: 600; fill: var(--navy-soft); }
.rule-danger { font-size: 17px; font-weight: 700; text-anchor: middle; letter-spacing: 0.06em; text-transform: uppercase; }
.rule-place { font-size: 20px; font-weight: 700; text-anchor: middle; fill: var(--brass-text) !important; }
.rule-farled { font-size: 19px; font-weight: 700; text-anchor: middle; fill: #7a2fa8 !important; }
.rule-north { font-size: 17px; font-weight: 700; text-anchor: middle; stroke: none; fill: var(--brass-text) !important; }
.rule-notes { list-style: none; display: grid; gap: 8px; margin: 16px 0 0; padding: 0; }
.rule-notes b { display: block; font-family: var(--serif); }
.marks { list-style: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; padding: 0; margin: 20px 0 0; }
.marks li { display: grid; justify-items: center; gap: 2px; padding: 16px 10px 14px; text-align: center; }
.marks svg { width: 54px; height: auto; margin-bottom: 8px; }
.marks b { font-family: var(--serif); }
.marks span { font-size: 0.88rem; color: var(--navy-soft); line-height: 1.35; }
.marks-note { margin: 24px 0 0; max-width: 46em; font-size: 1.05rem; }

/* The modes, each with a real screenshot in a phone frame. */
.tour { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; padding: 0; margin: 32px 0 0; }
.tour-item { display: grid; grid-template-columns: 172px minmax(0, 1fr); gap: 22px; align-items: center; padding: 20px; }
.phone { margin: 0; padding: 6px; background: var(--navy); border-radius: 26px; box-shadow: 0 10px 24px rgb(18 41 74 / 0.25); }
.phone img { width: 100%; height: auto; border-radius: 20px; }
.tour-kicker { margin: 0 0 4px; color: var(--brass-text); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.tour-item h3 { font-size: 1.5rem; }
.tour-item p:last-child { margin: 8px 0 0; color: var(--navy-soft); }
.shot-ipad { margin: 40px auto 0; max-width: 860px; }
.shot-ipad img { width: 100%; height: auto; border-radius: 14px; border: 1px solid var(--brass); box-shadow: 0 6px 16px rgb(18 41 74 / 0.16); }
.shot-ipad-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.shot-ipad figcaption { margin-top: 10px; text-align: center; font-size: 0.95rem; font-weight: 600; }

/* Night mode */
.night { background: var(--night-deep); color: var(--night-red); }
.night-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.night p { color: var(--night-soft); }
.night .section-lead { color: var(--night-soft); }
.night h2::before { background: var(--night-edge); }
.light-box {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 20px 20px 28px;
  background: var(--night-card);
  border: 1px solid var(--night-edge);
  border-radius: 14px;
}
.night-scene { width: 100%; height: auto; }
.night-phone { width: 190px; margin-top: 24px; background: #2a0705; box-shadow: 0 0 0 1px var(--night-edge), 0 12px 30px rgb(0 0 0 / 0.6); }
.lamp { animation: flash 6s steps(1) infinite; }
/* Fl(2) R 6s, with the app's times: 0,6 s of light, 1,2 s between the two flashes. */
@keyframes flash {
  0%   { opacity: 1; }
  10%  { opacity: 0; }
  30%  { opacity: 1; }
  40%  { opacity: 0; }
}
.light-code { font-family: var(--serif); font-weight: 700; font-size: 1.6rem; color: var(--night-red); }
.light-box p { margin: 0; text-align: center; }

/* What it doesn't do */
.nots { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; padding: 0; margin: 32px 0 0; }
.nots li { padding: 16px; font-weight: 600; }
.nots li span { display: block; font-weight: 400; color: var(--navy-soft); font-size: 0.98rem; margin-top: 2px; }

.warning { padding: 22px; border-left: 5px solid var(--wrong); }
.warning h2 { font-size: 1.4rem; }
.warning p { margin: 8px 0 0; }

/* Privacy and support */
.doc { padding-block: 12px 64px; }
.sheet { padding: clamp(20px, 4vw, 40px); }
.doc h1 { font-size: clamp(2rem, 6vw, 2.75rem); }
.doc h2 { font-size: 1.45rem; margin-top: 32px; }
.doc h3 { margin-top: 24px; font-size: 1.1rem; }
.doc h3 + p { margin-top: 4px; }
.lead { font-size: 1.15rem; }

.site-footer {
  padding: 32px 20px 44px;
  text-align: center;
  font-size: 0.95rem;
  background: var(--navy);
  color: var(--on-navy);
  border-top: 3px solid var(--brass);
}
.site-footer a { color: var(--on-navy); }
.site-footer a:hover { color: var(--brass-light); }
.site-footer :focus-visible { outline-color: var(--brass-light); }

@media (min-width: 1000px) {
  .scene { margin-top: -170px; }
}

@media (max-width: 820px) {
  .night-grid, .chart-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .section { padding-block: 52px; }
  .facts ul { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 20px; }
  .facts li:nth-child(odd) { padding-left: 0; border-left: 0; }
  .steps { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .steps::before { top: 0; bottom: 0; left: 21px; right: auto; border-top: 0; border-left: 2px dashed var(--brass); }
  .steps li { padding-left: 62px; min-height: 44px; }
  .steps li::before { position: absolute; left: 0; top: 0; margin: 0; }
  .rose { width: 96px; height: 96px; margin-bottom: 16px; }
  .marks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .helm-head, .rules, .tour { grid-template-columns: minmax(0, 1fr); }
  .rule { padding: 18px; }
  .helm-stage { height: clamp(460px, 76vh, 560px); }
  .helm-fallback { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .helm-fallback img { max-height: 300px; }
  .helm-panel { padding: 6px 8px; font-size: 0.75rem; }
  .helm-panel b { font-size: 0.82rem; }
  .is-ready .helm-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 10px; }
}

@media (max-width: 480px) {
  .tour-item { grid-template-columns: 116px minmax(0, 1fr); gap: 14px; padding: 14px; align-items: start; }
  .tour-item h3 { font-size: 1.25rem; }
  .phone { padding: 4px; border-radius: 18px; }
  .phone img { border-radius: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .beam, .bob, .swell, .lamp { animation: none; }
}
