/* keithdefreitas.com: a chart of north-west Trinidad, with Keith's words as its sailing directions. */

@font-face {
  font-family: "Literata";
  src: url("fonts/literata.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("fonts/literata-italic.woff2") format("woff2");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Depth tints are the only fills. */
  --deep: #ffffff;
  --shoal-1: #d6eaf5;
  --shoal-2: #9cc9e3;
  --land: #e5c35f;
  --ink: #14181c;
  --sea-ink: #1f4e6b;
  --mag: #8a0f5c;

  /* One chart minute rules the spacing; every gap is a whole number of quarter-minutes. */
  --minute: 2.5rem;
  --q: calc(var(--minute) / 4);

  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Atkinson Hyperlegible Next", "Helvetica Neue", Arial, sans-serif;

  --strip: 8px;
  --frame: calc(var(--q) * 2);
  --here: 3.25rem;

  color-scheme: light;
  accent-color: var(--mag);
  scrollbar-color: var(--sea-ink) var(--shoal-1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--deep);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--shoal-2); color: var(--ink); }

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

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--mag); }
:focus-visible { outline: 3px solid var(--mag); outline-offset: 3px; }

.skip {
  position: absolute;
  left: var(--frame);
  top: var(--frame);
  z-index: 10;
  padding: var(--q) calc(var(--q) * 2);
  background: var(--deep);
  border: 1px solid var(--ink);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1rem;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

/* ---------- The sheet: a neatline with graduated minute strips ---------- */

.sheet {
  position: relative;
  margin: var(--frame);
  border: 1px solid var(--ink);
  padding-inline: var(--strip);
}
.sheet::before,
.sheet::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--strip);
  background: repeating-linear-gradient(to bottom, var(--ink) 0 var(--minute), var(--deep) var(--minute) calc(var(--minute) * 2));
}
.sheet::before { left: 0; border-right: 1px solid var(--ink); }
.sheet::after {
  right: 0;
  border-left: 1px solid var(--ink);
  background: repeating-linear-gradient(to bottom, var(--deep) 0 var(--minute), var(--ink) var(--minute) calc(var(--minute) * 2));
}

/* ---------- Masthead chart ---------- */

.masthead { position: relative; border-bottom: 1px solid var(--ink); }
.chart { margin: 0; border-bottom: 1px solid var(--ink); }
.chart svg { width: 100%; height: auto; }
.chart-medium,
.chart-narrow { display: none; }

.chart .coast-band-2 { fill: none; stroke: var(--shoal-1); stroke-linejoin: round; }
.chart .coast-band-1 { fill: none; stroke: var(--shoal-2); stroke-linejoin: round; }
.chart .coast-land { fill: var(--land); stroke: var(--ink); stroke-linejoin: round; }
.chart .graticule { stroke: var(--sea-ink); stroke-opacity: 0.32; fill: none; }
.chart .scale-ink { fill: var(--ink); }
.chart .scale-paper { fill: var(--deep); stroke: var(--ink); }
.chart .coord { font-family: var(--sans); font-weight: 600; fill: var(--ink); letter-spacing: 0.04em; }
.chart .land-name { font-family: var(--sans); font-weight: 700; fill: var(--ink); letter-spacing: 0.2em; }
.chart .landmark { font-family: var(--sans); font-weight: 400; fill: var(--ink); letter-spacing: 0.04em; }
.chart .water-name { font-family: var(--serif); font-style: italic; fill: var(--sea-ink); letter-spacing: 0.32em; }
.chart .water-small { font-family: var(--serif); font-style: italic; fill: var(--sea-ink); letter-spacing: 0.12em; }
.chart .town { fill: var(--ink); }
.chart .landmark-mark { fill: var(--deep); stroke: var(--ink); }
.chart .rose { fill: none; stroke: var(--sea-ink); }
.chart .rose-fill { fill: var(--sea-ink); }
.chart .rose-n { font-family: var(--sans); font-weight: 700; fill: var(--sea-ink); }
.chart .track { fill: none; stroke: var(--mag); stroke-linecap: round; }
.chart .track-label { font-family: var(--serif); font-style: italic; fill: var(--mag); }
.chart .caution { font-family: var(--sans); font-weight: 700; fill: var(--mag); letter-spacing: 0.18em; }
.chart .reveal { fill: none; stroke: #fff; stroke-linecap: round; }
.chart .halo { paint-order: stroke; stroke: var(--land); stroke-width: 5px; stroke-linejoin: round; }

@media (prefers-reduced-motion: no-preference) {
  .chart .reveal { animation: draw-track 2.2s cubic-bezier(0.16, 1, 0.3, 1) 0.5s both; }
  .chart .track-label { animation: settle 0.9s cubic-bezier(0.16, 1, 0.3, 1) 1.9s both; }
}
@keyframes draw-track { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes settle { from { opacity: 0; } to { opacity: 1; } }

/* Title cartouche: a double neatline. Under the chart on narrow screens; set in the Caribbean Sea on wide ones. */
.cartouche {
  margin: calc(var(--q) * 3) calc(var(--q) * 4);
  padding: calc(var(--q) * 2) calc(var(--q) * 3);
  background: var(--deep);
  border: 1px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: 4px;
}
.cartouche h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2rem, 1rem + 2.2vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-wrap: balance;
}
.cartouche p {
  margin: var(--q) 0 0;
  padding-top: var(--q);
  border-top: 1px solid var(--ink);
  font-style: italic;
  font-size: clamp(1rem, 0.8rem + 0.4vw, 1.2rem);
  line-height: 1.4;
  color: var(--sea-ink);
  text-wrap: balance;
}

@media (min-width: 80rem) {
  .chart { border-bottom: 0; }
  .cartouche {
    position: absolute;
    left: 4.2%;
    top: 7.5%;
    width: 31%;
    margin: 0;
    padding: calc(var(--q) * 2) calc(var(--q) * 2) calc(var(--q) * 2) calc(var(--q) * 3);
  }
  .cartouche h1 { font-size: 3.15vw; }
  .cartouche p { font-size: max(1rem, 1.15vw); }
}

/* ---------- Body: shoal rail + deep-water column ---------- */

.body {
  display: grid;
  grid-template-columns: 19rem minmax(0, 1fr);
}

.rail {
  background: var(--shoal-1);
  border-right: 1px solid var(--ink);
  padding: calc(var(--q) * 5) calc(var(--q) * 4);
}

.legend {
  position: sticky;
  top: var(--minute);
  border: 1px solid var(--ink);
  background: var(--deep);
  scroll-margin-top: var(--minute);
}
.legend h2 {
  margin: 0;
  padding: var(--q) calc(var(--q) * 2);
  border-bottom: 1px solid var(--ink);
  background: var(--shoal-2);
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.legend ol { list-style: none; margin: 0; padding: var(--q) 0; }
.legend a {
  display: grid;
  grid-template-columns: 1.125rem 1fr;
  align-items: center;
  gap: var(--q);
  padding: var(--q) calc(var(--q) * 2);
  min-height: 2.75rem;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.3;
  text-decoration: none;
  color: var(--ink);
}
.legend a:hover { color: var(--mag); text-decoration: underline; }
.fix { width: 1.125rem; height: 1.125rem; }
.fix circle:first-child { fill: none; stroke: var(--mag); stroke-width: 1.6; }
.fix circle:last-child { fill: var(--mag); }
.legend .fix { opacity: 0; transition: opacity 0.25s ease-out; }
.legend a[aria-current="true"] { color: var(--mag); font-weight: 600; }
.legend a[aria-current="true"] .fix { opacity: 1; }

/* Position strip: on narrow screens the fix travels with the reader. */
.here { display: none; }

main {
  display: grid;
  grid-template-columns:
    [full-start] minmax(var(--minute), calc(var(--minute) * 2))
    [col-start] minmax(0, 34em)
    [col-end] minmax(var(--minute), 1fr)
    [full-end];
  padding-bottom: calc(var(--minute) * 2);
}
main > * { grid-column: col; }

section { scroll-margin-top: var(--minute); }

/* Section openers: a double neatline, more space above than below. */
main h2 {
  position: relative;
  margin: calc(var(--minute) * 2) 0 calc(var(--q) * 2);
  padding-top: calc(var(--q) * 2);
  border-top: 1px solid var(--ink);
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.25rem, 1.5rem + 2vw, 3.25rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
main h2::before {
  content: "";
  position: absolute;
  inset: 3px 0 auto;
  border-top: 1px solid var(--ink);
}
main section:first-child h2 { margin-top: calc(var(--q) * 5); }

main p { margin: 0 0 calc(var(--q) * 2); max-width: 34em; text-wrap: pretty; }

/* Particulars and lists: chart notes, ruled in hairlines. */
.particulars,
.ruled {
  margin: calc(var(--q) * 3) 0 var(--q);
  padding: 0;
  max-width: 34em;
  border-top: 1px solid var(--ink);
}
.particulars div,
.ruled li {
  display: grid;
  grid-template-columns: minmax(0, 11rem) minmax(0, 1fr);
  gap: calc(var(--q) * 2);
  padding: var(--q) 0;
  border-bottom: 1px solid var(--shoal-2);
}
.particulars dt {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  line-height: 1.6;
  padding-top: 0.15em;
  color: var(--sea-ink);
}
.particulars dd { margin: 0; }
.ruled { list-style: none; }
.ruled.plain li { grid-template-columns: minmax(0, 1fr); }
.ruled .where { display: block; }
.ruled .qual {
  display: block;
  font-family: var(--sans);
  font-size: 1.0625rem;
  color: var(--sea-ink);
}

/* ---------- Lettered plans: photographs framed as harbour-plan insets ---------- */

.plan {
  --plan-strip: 5px;
  position: relative;
  margin: 0;
  padding-inline: var(--plan-strip);
  background: var(--deep);
  border: 1px solid var(--ink);
}
.plan::before,
.plan::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--plan-strip);
  background: repeating-linear-gradient(to bottom, var(--ink) 0 calc(var(--q) * 2), var(--deep) calc(var(--q) * 2) calc(var(--q) * 4));
}
.plan::before { left: 0; border-right: 1px solid var(--ink); }
.plan::after {
  right: 0;
  border-left: 1px solid var(--ink);
  background: repeating-linear-gradient(to bottom, var(--deep) 0 calc(var(--q) * 2), var(--ink) calc(var(--q) * 2) calc(var(--q) * 4));
}
.plan-title {
  display: flex;
  align-items: center;
  gap: var(--q);
  margin: 0;
  padding: var(--q) calc(var(--q) * 2);
  border-bottom: 1px solid var(--ink);
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  line-height: 1.3;
}
.plan-letter {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--ink);
  letter-spacing: 0;
  font-size: 0.9375rem;
}
.plan-photos {
  list-style: none;
  margin: 0;
  padding: calc(var(--q) * 2);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: calc(var(--q) * 2);
}
.plan a { display: block; border: 1px solid var(--ink); }
.plan a:hover { outline: 1px solid var(--mag); outline-offset: 2px; }
.plan img { width: 100%; max-width: 800px; height: auto; }
.plan-single {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: calc(var(--q) * 2);
  padding: calc(var(--q) * 2);
  align-items: end;
}
.plan-single .plan-caption {
  margin: 0;
  padding: 0 0 var(--q);
  border-bottom: 1px solid var(--ink);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.375rem;
  color: var(--ink);
}

/* The portrait is plan A: shown at its own 162px, never enlarged. */
.plan-portrait { width: max-content; margin: 0 0 calc(var(--q) * 3); }
.plan-portrait .plan-title { max-width: calc(162px + var(--q) * 4); letter-spacing: 0.14em; }
.plan-portrait .portrait-frame { padding: calc(var(--q) * 2); }
.plan-portrait img { width: 162px; height: auto; border: 1px solid var(--ink); }

/* ---------- Photographs: the land band ---------- */

.photographs {
  grid-column: full;
  display: grid;
  grid-template-columns: subgrid;
  background: var(--land);
  border-block: 1px solid var(--ink);
  margin-top: calc(var(--minute) * 2);
  padding-bottom: calc(var(--q) * 6);
}
.photographs > * { grid-column: col; }
.photographs h2 { margin-top: calc(var(--q) * 5); }
.photographs .plans {
  grid-column: col-start / full-end;
  padding-right: var(--minute);
  display: grid;
  gap: calc(var(--q) * 3);
  max-width: calc(52rem + var(--minute));
}

/* ---------- A note from New Jersey ---------- */

.note {
  margin: var(--q) 0 0;
  max-width: 34em;
  border: 1px solid var(--mag);
  outline: 1px solid var(--mag);
  outline-offset: 4px;
  padding: calc(var(--q) * 2) calc(var(--q) * 3);
}
.note blockquote { margin: 0; }
.note blockquote p {
  margin: 0;
  font-style: italic;
  font-size: clamp(1.5rem, 1.1rem + 1.2vw, 2.125rem);
  line-height: 1.3;
}
.note figcaption {
  margin-top: var(--q);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mag);
}

/* ---------- Imprint ---------- */

.imprint {
  border-top: 1px solid var(--ink);
  padding: calc(var(--q) * 2) var(--minute);
  display: flex;
  flex-wrap: wrap;
  gap: var(--q) calc(var(--q) * 4);
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--sans);
  font-size: 0.9375rem;
  line-height: 1.5;
}
.imprint p { margin: 0; }
.imprint .caution { color: var(--mag); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.8125rem; }

/* ---------- Wide desktop: the portrait plan beside the welcome ---------- */

@media (min-width: 90rem) {
  .hello { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: calc(var(--q) * 6); }
  .hello h2 { grid-column: 1 / -1; }
  .hello .plan-portrait { grid-column: 2; grid-row: 2 / span 3; }
  .hello p { grid-column: 1; }
}

/* ---------- Tablet: the legend moves above the column, the fix travels in a strip ---------- */

@media (max-width: 63.99rem) {
  .body { grid-template-columns: minmax(0, 1fr); }
  .rail {
    border-right: 0;
    padding: calc(var(--q) * 4);
  }
  .legend { position: static; max-width: 40rem; }
  .legend ol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  main { grid-template-columns: [full-start] var(--minute) [col-start] minmax(0, 34em) [col-end] minmax(var(--minute), 1fr) [full-end]; }
  section { scroll-margin-top: calc(var(--here) + var(--q) * 2); }

  .here {
    display: block;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--shoal-1);
    border-block: 1px solid var(--ink);
  }
  .here a {
    display: flex;
    align-items: center;
    gap: var(--q);
    min-height: var(--here);
    padding: 0 calc(var(--q) * 2);
    font-family: var(--sans);
    font-size: 1.0625rem;
    text-decoration: none;
    color: var(--ink);
  }
  .here .here-name { color: var(--mag); font-weight: 600; }
  .here .here-back {
    margin-left: auto;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.25em;
  }
  .here a:hover .here-back { color: var(--mag); }
}

@media (min-width: 46rem) and (max-width: 63.99rem) {
  .chart-wide { display: none; }
  .chart-medium { display: block; }
}

/* ---------- Phone: the narrow chart window ---------- */

@media (max-width: 45.99rem) {
  :root { --strip: 5px; --frame: calc(var(--q)); --minute: 2rem; }
  body { font-size: 1.1875rem; line-height: 1.62; }
  .chart-wide { display: none; }
  .chart-narrow { display: block; }
  .cartouche { margin: calc(var(--q) * 3) calc(var(--q) * 2); padding: calc(var(--q) * 2); }
  .rail { padding: calc(var(--q) * 3) calc(var(--q) * 2); }
  .legend ol { grid-template-columns: minmax(0, 1fr); }
  main { grid-template-columns: [full-start] calc(var(--q) * 2) [col-start] minmax(0, 1fr) [col-end] calc(var(--q) * 2) [full-end]; }
  main h2 { margin-top: calc(var(--q) * 9); }
  .particulars div,
  .ruled li { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .photographs .plans { grid-column: full; padding: 0 var(--q); }
  .plan-photos,
  .plan-single { grid-template-columns: minmax(0, 1fr); padding: var(--q); gap: var(--q); }
  .plan-title { letter-spacing: 0.14em; }
  .note { padding: calc(var(--q) * 2); }
  .imprint { padding: calc(var(--q) * 2); flex-direction: column; }
}

@media print {
  .sheet::before, .sheet::after, .rail, .here, .skip { display: none; }
  .body { grid-template-columns: minmax(0, 1fr); }
  .photographs { background: none; }
}
