/* The Sunwake Project — site styles.
   One stylesheet, no framework, no build step. Light and dark both first-class. */

:root {
  --ink: #16303f;
  --ink-2: #33505f;
  --muted: #6c8494;
  --rule: #d8e2e8;
  --bg: #fbfaf7;
  --panel: #ffffff;
  --water: #2b7a9b;
  --accent: #c1611f;
  --gold: #b08d2e;
  --hull: #16303f;
  --code-bg: #f1f0ea;
  --shadow: 0 1px 2px rgba(22, 48, 63, .06), 0 8px 24px rgba(22, 48, 63, .05);
  --max: 78rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6eef2;
    --ink-2: #c3d2da;
    --muted: #8aa3b0;
    --rule: #24404e;
    --bg: #0e1c24;
    --panel: #14262f;
    --water: #5cb3d0;
    --accent: #e2884a;
    --gold: #d3b45c;
    --hull: #0a161d;
    --code-bg: #10222b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16.5px/1.62 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
        "Source Serif 4", serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------------------------------------------------------------- masthead */

header.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(1.4) blur(6px);
}

.masthead .inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: .7rem 1.4rem;
  display: flex;
  align-items: baseline;
  gap: 1.6rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.02rem;
  white-space: nowrap;
}

.brand .mark { color: var(--water); }

.masthead nav {
  display: flex;
  gap: 1.15rem;
  flex-wrap: wrap;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: .82rem;
  letter-spacing: .02em;
}

.masthead nav a {
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
}

.masthead nav a:hover { color: var(--ink); }
.masthead nav a.active { color: var(--ink); border-bottom-color: var(--accent); }

/* -------------------------------------------------------------- page shell */

.shell {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2.2rem 1.4rem 5rem;
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  gap: 3rem;
}

.shell.wide { grid-template-columns: minmax(0, 1fr); }

aside.sidebar {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: .845rem;
  line-height: 1.5;
  align-self: start;
  position: sticky;
  top: 4.2rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

aside h3 {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin: 0 0 .6rem;
  font-weight: 600;
}

aside ol { list-style: none; margin: 0 0 1.8rem; padding: 0; counter-reset: doc; }

aside ol li { counter-increment: doc; margin: 0 0 .3rem; }

aside ol li a {
  color: var(--ink-2);
  text-decoration: none;
  display: block;
  padding: .18rem .5rem .18rem 2rem;
  border-radius: 4px;
  position: relative;
}

aside ol li a::before {
  content: counter(doc);
  position: absolute;
  left: .5rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: .78rem;
}

aside ol li a:hover { background: var(--code-bg); color: var(--ink); }
aside ol li a.active { background: var(--code-bg); color: var(--ink); font-weight: 600; }

aside .toc { list-style: none; padding: 0; margin: 0; }
aside .toc li { margin: .18rem 0; }
aside .toc a { color: var(--muted); text-decoration: none; font-size: .8rem; }
aside .toc a:hover { color: var(--water); }

/* ------------------------------------------------------------------ prose */

article { min-width: 0; }

article h1 {
  font-size: 2.05rem;
  line-height: 1.18;
  margin: 0 0 1.1rem;
  letter-spacing: -.012em;
  font-weight: 600;
}

article h2 {
  font-size: 1.32rem;
  margin: 2.6rem 0 .8rem;
  padding-top: .9rem;
  border-top: 1px solid var(--rule);
  font-weight: 600;
  letter-spacing: -.005em;
}

article h3 { font-size: 1.08rem; margin: 1.9rem 0 .5rem; font-weight: 600; }
article h4 { font-size: .95rem; margin: 1.4rem 0 .4rem; font-weight: 600; color: var(--ink-2); }

.anchor {
  color: var(--rule);
  text-decoration: none;
  margin-left: .45rem;
  font-weight: 400;
  opacity: 0;
  transition: opacity .12s;
}

h1:hover .anchor, h2:hover .anchor, h3:hover .anchor { opacity: 1; }

article p { margin: 0 0 1rem; }
article strong { font-weight: 650; color: var(--ink); }

article a { color: var(--water); text-decoration-thickness: 1px; text-underline-offset: 2px; }
article a:hover { color: var(--accent); }

article ul, article ol { margin: 0 0 1.1rem; padding-left: 1.35rem; }
article li { margin: .3rem 0; }
article li > ul, article li > ol { margin: .35rem 0 .2rem; }

article hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }
article hr + h2 { border-top: 0; padding-top: .2rem; margin-top: 1.2rem; }

article blockquote {
  margin: 1.2rem 0;
  padding: .1rem 0 .1rem 1.1rem;
  border-left: 3px solid var(--water);
  color: var(--ink-2);
  background: none;
}

article blockquote p { margin: .55rem 0; }

code {
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: .855em;
  background: var(--code-bg);
  padding: .1em .34em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: .9rem 1rem;
  overflow-x: auto;
  font-size: .84rem;
  line-height: 1.5;
}

pre code { background: none; padding: 0; font-size: inherit; }

/* ----------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; margin: 1.1rem 0 1.5rem; }

table {
  border-collapse: collapse;
  width: 100%;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: .845rem;
  line-height: 1.45;
}

thead th {
  text-align: left;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1.5px solid var(--ink-2);
  padding: .45rem .7rem .45rem 0;
  white-space: nowrap;
}

tbody td {
  border-bottom: 1px solid var(--rule);
  padding: .42rem .7rem .42rem 0;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}

tbody tr:hover { background: var(--code-bg); }

/* ------------------------------------------------------------------- home */

.hero {
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 1.6rem 1.8rem 1.2rem;
  margin-bottom: 2.4rem;
}

.hero h1 { font-size: 2.5rem; margin: 0 0 .5rem; letter-spacing: -.02em; }
.hero .tagline { font-size: 1.12rem; color: var(--ink-2); margin: 0 0 1.2rem; max-width: 46rem; }
.hero figure {
  margin: 0 -.6rem;
  overflow: hidden;
  border-radius: 7px;
  background: #dce7ec;
}
.hero img {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 1672 / 941;
  object-fit: cover;
}

.status {
  display: inline-block;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .72rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: .18rem .6rem;
  margin-bottom: .9rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  margin: 0 0 2.4rem;
}

.stat { background: var(--panel); padding: .85rem 1rem; }
.stat .k {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .68rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: .18rem;
}
.stat .v { font-size: 1.28rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: .72rem; font-weight: 400; color: var(--muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
  margin: 1.2rem 0 2.4rem;
}

.card {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--panel);
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform .12s, box-shadow .12s;
}

.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card .n {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .68rem;
  letter-spacing: .09em;
  color: var(--accent);
  text-transform: uppercase;
}
.card h3 { margin: .25rem 0 .35rem; font-size: 1.02rem; }
.card p { margin: 0; font-size: .87rem; color: var(--ink-2); line-height: 1.5; }

/* -------------------------------------------------------- hull explorer */

.explorer {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.viewport {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--panel);
  padding: .55rem .7rem .35rem;
  position: relative;
  min-width: 0;
}

.viewport h3 {
  margin: 0 0 .2rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .7rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.viewport h3 .hint { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .74rem; }

.viewport canvas { width: 100%; display: block; }

#v-profile { grid-column: 1; grid-row: 1; }
#v-section { grid-column: 2; grid-row: 1 / span 2; }
#v-plan    { grid-column: 1; grid-row: 2; }

.controls {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--panel);
  padding: 1rem 1.2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1.1rem 2rem;
  margin-bottom: 1.6rem;
}

.control label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: .35rem;
}

.control label b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-size: .92rem;
  font-weight: 600;
}

input[type=range] {
  width: 100%;
  accent-color: var(--water);
  height: 1.2rem;
}

.readout {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .8rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: .3rem 1.4rem;
  color: var(--ink-2);
  margin-top: .2rem;
}

.readout div { display: flex; justify-content: space-between; gap: .8rem;
               border-bottom: 1px dotted var(--rule); padding: .12rem 0; }
.readout b { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }

.toggles {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .8rem;
  color: var(--ink-2);
}

.toggles label { display: flex; align-items: center; gap: .35rem; cursor: pointer; }

/* ------------------------------------------------------------------ misc */

figure.plate {
  margin: 0 0 2rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--panel);
  padding: .9rem;
}

figure.plate img { width: 100%; height: auto; display: block; }

figure.plate figcaption {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .8rem;
  color: var(--muted);
  margin-top: .6rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.lede {
  font-size: 1.06rem;
  color: var(--ink-2);
  border-left: 3px solid var(--water);
  padding-left: 1.1rem;
  margin: 0 0 2rem;
}

.lede em { font-style: normal; }

footer.foot {
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
  padding: 1.6rem 1.4rem 3rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .8rem;
  color: var(--muted);
}

footer.foot .inner { max-width: var(--max); margin: 0 auto; display: flex;
                     justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }

footer.foot a { color: var(--muted); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .85rem;
}

.pager a { text-decoration: none; color: var(--ink-2); }
.pager a:hover { color: var(--water); }
.pager span { color: var(--muted); font-size: .7rem; text-transform: uppercase;
              letter-spacing: .08em; display: block; }

@media (max-width: 62rem) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 1.6rem; }
  aside.sidebar { position: static; max-height: none; border-bottom: 1px solid var(--rule);
                  padding-bottom: 1rem; }
  .explorer { grid-template-columns: minmax(0, 1fr); }
  #v-profile, #v-section, #v-plan { grid-column: 1; grid-row: auto; }
}

@media print {
  .masthead, aside.sidebar, .pager, footer.foot { display: none; }
  .shell { grid-template-columns: 1fr; padding: 0; }
  body { background: #fff; color: #000; }
}
