:root {
  /* The hero photo is dark in every theme, so the page commits to dark. */
  color-scheme: dark;
  --fg: #f2f5f8;
  --fg-dim: #b9c3cd;
  --bg: #0d1117;
  --nav-w: 15rem;
  --rule: rgba(242, 245, 248, 0.18);
  --rule-strong: rgba(242, 245, 248, 0.45);
  --accent: #ff8f6b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Background photo ---------- */

/* Fixed, so it sits outside the grid flow and spans the whole viewport. */
.hero {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Keep the storm wall and horizon in frame as the viewport narrows. */
  object-position: 60% 50%;
  display: block;
  /* Lifts the photo out of the shadows a touch. */
  filter: brightness(1.12);
}

/* Scrim: weighted toward the content column and the bottom edge, where the
   headline and tagline sit. Kept light — just enough for legible text. */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 62% 42%, rgba(0, 0, 0, 0.26), transparent 68%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0.04) 40%, rgba(0, 0, 0, 0.42));
}

/* ---------- Nav pane ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 1;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  padding: 2rem 1.75rem;
  border-right: 1px solid var(--rule);
  /* Fallback for browsers without backdrop-filter: opaque enough to stay legible. */
  background: rgba(13, 17, 23, 0.82);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .nav {
    background: rgba(13, 17, 23, 0.55);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    backdrop-filter: blur(14px) saturate(120%);
  }
}

.wordmark {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg);
  text-decoration: none;
}

.nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.nav-links a {
  display: inline-block;
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  padding: 0.15rem 0;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-links a:hover {
  color: var(--fg);
  border-bottom-color: var(--rule);
}

/* Marks the page you are currently on. */
.nav-links a[aria-current="page"] {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

a:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ---------- Content column ---------- */

.content {
  position: relative;
  z-index: 1;
  display: grid;
  /* Headline centers in the flexible row; tagline sits on the bottom edge. */
  grid-template-rows: 1fr auto;
  gap: 2rem;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(2rem, 5vw, 4.5rem);
}

.headline {
  align-self: center;
  max-width: 34ch;
  margin: 0;
  font-size: clamp(1.9rem, 4.4vw, 3.6rem);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 28px rgba(0, 0, 0, 0.7);
}

/* The question sits on its own line beneath the first sentence. */
.headline span {
  display: block;
}

.tagline {
  /* Lifted off the bottom edge so it reads with the headline, not apart. */
  margin: 0 0 clamp(2.5rem, 11vh, 8rem);
  padding-top: 1.6rem;
  border-top: 3px solid var(--rule-strong);
  max-width: 46ch;
  font-size: clamp(1.05rem, 1.7vw, 1.4rem);
  line-height: 1.5;
  color: var(--fg-dim);
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.75);
}

.tagline strong {
  display: block;
  color: var(--fg);
  font-weight: 600;
  font-size: 1.12em;
  letter-spacing: 0.01em;
}

/* ---------- Interior pages: content starts at the top and scrolls ---------- */

.content--page {
  grid-template-rows: auto auto;
  align-content: start;
  gap: 2.5rem;
  padding-top: clamp(2.5rem, 6vh, 4.5rem);
  padding-bottom: clamp(3rem, 8vh, 6rem);
}

.page-head {
  max-width: 60ch;
}

.page-title {
  margin: 0;
  font-size: clamp(1.9rem, 3.6vw, 3rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 28px rgba(0, 0, 0, 0.7);
}

.page-intro {
  margin: 1rem 0 0;
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  line-height: 1.6;
  color: var(--fg-dim);
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.75);
}

/* ---------- Black panel ---------- */

.panel {
  background: #000;
  border: 1px solid rgba(242, 245, 248, 0.14);
  border-radius: 4px;
  padding: clamp(1.5rem, 3.5vw, 2.75rem);
  max-width: 62rem;
  width: 100%;
}

/* ---------- Form ---------- */

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0 1.5rem;
}

.field {
  margin: 0 0 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field label {
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.req {
  color: var(--accent);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--fg);
  background: #0b0b0c;
  border: 1px solid rgba(242, 245, 248, 0.2);
  border-radius: 3px;
  padding: 0.7rem 0.8rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea {
  resize: vertical;
  min-height: 8rem;
  line-height: 1.55;
}

.field input::placeholder,
.field textarea::placeholder {
  color: rgba(185, 195, 205, 0.5);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--fg);
  box-shadow: 0 0 0 3px rgba(242, 245, 248, 0.14);
}

/* Only flag invalid fields after a submit attempt, not while typing. */
.was-validated .field input:invalid,
.was-validated .field textarea:invalid,
.was-validated .field select:invalid {
  border-color: var(--accent);
}

/* Honeypot: off-screen rather than display:none, which some bots skip. */
.hp {
  position: absolute;
  left: -9999px;
  opacity: 0;
  height: 0;
  width: 0;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.btn {
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #0d1117;
  background: var(--fg);
  border: 1px solid var(--fg);
  border-radius: 3px;
  padding: 0.8rem 2.25rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: transparent;
  color: var(--fg);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.form-error {
  margin: 0;
  color: var(--accent);
  font-size: 0.95rem;
  line-height: 1.5;
}

.form-success h2 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.25rem, 2.2vw, 1.6rem);
  font-weight: 600;
  line-height: 1.25;
}

.form-success p {
  margin: 0;
  color: var(--fg-dim);
  line-height: 1.6;
}

/* ---------- Secondary buttons ---------- */

/* Use alongside .btn. Outline only, so the primary action keeps the only
   filled shape on the page. */
.btn--ghost {
  color: var(--fg);
  background: transparent;
  border-color: var(--rule-strong);
  font-weight: 500;
  padding-inline: 1.5rem;
}

.btn--ghost:hover:not(:disabled) {
  background: rgba(242, 245, 248, 0.08);
  border-color: var(--fg);
}

.btn--deny {
  color: var(--accent);
  background: transparent;
  border-color: var(--accent);
  font-weight: 500;
  padding-inline: 1.5rem;
}

.btn--deny:hover:not(:disabled) {
  background: var(--accent);
  color: #0d1117;
}

/* ---------- Account pages ---------- */

.panel--narrow {
  max-width: 34rem;
}

.form-rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2rem 0 1.75rem;
}

.form-subhead {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.form-note {
  margin: 0 0 1.25rem;
  color: var(--fg-dim);
  font-size: 0.9rem;
  line-height: 1.55;
}

.form-note a {
  color: var(--fg-dim);
}

.form-note a:hover {
  color: var(--fg);
}

.form-actions + .form-note {
  margin-top: 1.25rem;
  margin-bottom: 0;
}

.detail-list {
  margin: 0 0 1.75rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem 1.5rem;
}

.detail-list dt {
  color: var(--fg-dim);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Portal ---------- */

.nav-footer {
  /* Pins the account block to the bottom of the sidebar. */
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}

.nav-user {
  margin: 0;
  color: var(--fg-dim);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.nav-back {
  letter-spacing: 0.02em;
}

.btn--small {
  font-size: 0.85rem;
  padding: 0.45rem 1.1rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
  max-width: 62rem;
}

.card {
  display: block;
  background: #000;
  border: 1px solid rgba(242, 245, 248, 0.14);
  border-radius: 4px;
  padding: 1.5rem;
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--rule-strong);
}

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.card p {
  margin: 0;
  color: var(--fg-dim);
  font-size: 0.92rem;
  line-height: 1.55;
}

/* Tables can exceed the panel on narrow screens; scroll them, not the page. */
.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.7rem 1rem 0.7rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}

.data-table th {
  color: var(--fg-dim);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table .col-check {
  text-align: center;
  padding-right: 0;
  width: 1%;
  white-space: nowrap;
}

.data-table input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--fg);
  cursor: pointer;
}

.table-empty {
  color: var(--fg-dim);
}

/* A portal view stacks its heading and panels with the same rhythm as the
   page grid on single-purpose pages. :not([hidden]) so it never overrides
   the hidden attribute. */
.view:not([hidden]) {
  display: grid;
  gap: 2.5rem;
  align-content: start;
}

/* ---------- Newsletter Agent ---------- */

.nl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 1rem;
  max-width: 62rem;
}

.nl-grid .panel {
  padding: clamp(1.25rem, 2.5vw, 1.75rem);
}

.nl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0 0 1.25rem;
}

.nl-label {
  margin: 0 0 0.5rem;
  color: var(--fg-dim);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Calendar: pick any day, the whole Monday-Sunday week is selected. */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.cal-month {
  margin: 0;
  font-weight: 600;
}

.cal-nav {
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 3px;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
}

.cal-nav:hover {
  border-color: var(--rule-strong);
}

.cal-weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-weekdays span {
  text-align: center;
  color: var(--fg-dim);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-bottom: 0.35rem;
}

.cal-day {
  font: inherit;
  font-size: 0.9rem;
  color: var(--fg);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0.45rem 0;
  cursor: pointer;
}

.cal-day:hover {
  border-color: var(--rule-strong);
}

.cal-day--outside {
  color: rgba(185, 195, 205, 0.45);
}

.cal-day--today {
  border-color: var(--rule-strong);
}

.cal-day--selected {
  background: rgba(242, 245, 248, 0.14);
}

.cal-day:focus-visible,
.cal-nav:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.nl-week-label {
  margin: 1rem 0 0.25rem;
  font-weight: 600;
}

.nl-week-status {
  margin: 0;
  color: var(--fg-dim);
  font-size: 0.9rem;
}

.nl-week-status--yes {
  color: var(--fg);
}

/* Progress narration for background jobs. */
.workflow-log {
  height: 15rem;
  overflow-y: auto;
  background: #0b0b0c;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.75rem 0.9rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

.workflow-log p {
  margin: 0 0 0.3rem;
  color: var(--fg-dim);
  overflow-wrap: anywhere;
}

.workflow-log .workflow-log-error {
  color: var(--accent);
}

/* Data files and recipients: one row per item, remove button on the right. */
.nl-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nl-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--rule);
}

.nl-list li:last-child {
  border-bottom: 0;
}

.nl-file {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.nl-file-meta {
  color: var(--fg-dim);
  font-size: 0.82rem;
}

.link-button {
  font: inherit;
  color: var(--fg);
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.icon-button {
  flex: none;
  font: inherit;
  color: var(--fg-dim);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 3px;
  width: 1.9rem;
  height: 1.9rem;
  cursor: pointer;
}

.icon-button:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}

.nl-recipient-form {
  display: flex;
  gap: 0.6rem;
  margin: 0 0 0.75rem;
}

.nl-recipient-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 0.95rem;
  color: var(--fg);
  background: #0b0b0c;
  border: 1px solid rgba(242, 245, 248, 0.2);
  border-radius: 3px;
  padding: 0.5rem 0.7rem;
}

.nl-recipient-form input:focus {
  outline: none;
  border-color: var(--fg);
  box-shadow: 0 0 0 3px rgba(242, 245, 248, 0.14);
}

.nl-recipient-form + .form-error {
  margin-bottom: 0.75rem;
}

/* The generated newsletter, rendered from markdown. */
.nl-article {
  max-width: 72ch;
  line-height: 1.65;
}

.nl-article h2 {
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule-strong);
  font-size: 1.25rem;
}

.nl-article h2:first-child {
  margin-top: 0;
}

.nl-article h3 {
  margin: 1.4rem 0 0.4rem;
  font-size: 1.02rem;
}

.nl-article p,
.nl-article li {
  color: var(--fg-dim);
}

.nl-article p {
  margin: 0 0 0.9rem;
}

.nl-article ul {
  margin: 0 0 0.9rem;
  padding-left: 1.3rem;
}

/* ---------- Narrow screens: nav becomes a top bar ---------- */

@media (max-width: 700px) {
  body {
    grid-template-columns: 1fr;
  }

  .nav {
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 1rem;
    padding: 1rem 1.25rem;
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }

  .nav-links {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
  }

  .detail-list {
    grid-template-columns: 1fr;
    gap: 0.2rem 0;
  }

  .detail-list dd {
    margin-bottom: 0.9rem;
  }

  .content {
    /* The nav bar now consumes part of the viewport above this column. */
    min-height: 0;
    padding: clamp(2.5rem, 9vw, 4rem) 1.5rem 2rem;
    gap: 3rem;
  }

  .headline {
    align-self: start;
  }
}

/* Below ~440px the wordmark and both links cannot share one row without
   clipping, so stack them into two rows. */
@media (max-width: 440px) {
  .nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .form-actions .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-links a {
    transition: none;
  }
}
