/* Loaded last, on every page. Layout fixes for the home page first, then the
   parts added later: contact form, status line, case studies, notes, 404. */

/* ---------- Navigation: one line, and the menu button takes over early ---------- */
.nav-menu {
  gap: 1.1rem;
}
.nav-menu .nav-link,
.nav-menu .nav-cta {
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .nav-menu {
    display: none;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .nav-menu.open {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 1.5rem;
    gap: 1.25rem;
    max-height: calc(100vh - var(--nav-height));
    max-height: calc(100svh - var(--nav-height));
    overflow-y: auto;
  }
}

/* ---------- Nothing smaller than 12px ---------- */
.brand-sub,
.search-kbd,
.live-pill,
.card-badge,
.edu-badge,
.modal-tag,
.modal-stack-pill,
.arch-tab-sub,
.arch-badge,
.arch-pills span,
.card-metrics strong {
  font-size: 0.75rem;
}

/* ---------- Project cards: room for a second link ---------- */
.card-actions {
  flex-wrap: wrap;
  gap: 0.75rem;
}
.card-action-group {
  align-items: center;
}
.card-btn-case {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 0.4rem 0.2rem;
  border-bottom: 1px solid var(--line-strong);
  transition: color 0.2s, border-color 0.2s;
}
.card-btn-case:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- Contact: form beside the two info cards ---------- */
.contact-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: start;
}
.contact-card-form {
  grid-row: span 2;
}
.contact-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.25rem;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
.form-field {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}
.form-field > span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.form-field input,
.form-field textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-field textarea {
  resize: vertical;
  min-height: 7.5rem;
  line-height: 1.5;
}
.form-field input:focus-visible,
.form-field textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* Hidden from people; only scripts fill it in. */
.form-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.contact-form .btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}
.form-status {
  min-height: 1.4em;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.form-status.is-ok {
  color: var(--status-green);
}
.form-status.is-error {
  color: var(--accent);
}
.contact-alt {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.contact-alt-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}
.contact-alt .copy-field {
  margin-top: 0.5rem;
}
a.copy-text:hover {
  color: var(--accent);
}

/* ---------- Footer: live status line ---------- */
.site-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}
.site-status[hidden] {
  display: none;
}
.site-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-green);
  box-shadow: 0 0 8px var(--status-green);
}
.site-status.is-slow .site-status-dot {
  background: #f5b041;
  box-shadow: 0 0 8px #f5b041;
}
.site-status.is-down .site-status-dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.footer-links {
  flex-wrap: wrap;
}

/* ---------- Tablets and phones ---------- */
@media (max-width: 860px) {
  .contact-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .contact-card-form {
    grid-row: auto;
  }
}

@media (max-width: 760px) {
  /* The constellation keeps the top third; headline and buttons fit below it. */
  .hero-backdrop {
    height: 34vh;
    height: 34svh;
  }
  .hero-container {
    padding-top: 27vh;
    padding-top: 27svh;
  }
  .hero-eyebrow {
    font-size: 0.75rem;
    margin-bottom: 1rem;
  }
  .hero-title {
    font-size: 2.15rem;
    line-height: 1.05;
    margin-bottom: 0.9rem;
  }
  .hero-description {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 1.25rem;
  }
  .hero-desc-more {
    display: none;
  }
  .hero-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 2.25rem;
  }
  .hero-actions .btn {
    justify-content: center;
    text-align: center;
    padding: 0.7rem 0.6rem;
    font-size: 0.875rem;
    min-height: 44px;
  }
  .hero-actions .btn svg {
    display: none;
  }
  .hero-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding-top: 1.5rem;
  }
  .stat-card {
    padding: 0.9rem 1rem;
  }

  /* A shorter page: tighter sections, and the tag rows on cards step aside. */
  .section {
    padding: 3.25rem 0;
  }
  .card-features {
    display: none;
  }
  .projects-grid.is-short .project-card:nth-of-type(n+7) {
    display: none !important;
  }
  .projects-more:not([hidden]) {
    display: block;
  }
  .section-subheading {
    margin-bottom: 1.75rem;
  }
  .skill-group-note,
  .timeline-tags {
    display: none;
  }
  .timeline-item {
    margin-bottom: 1.5rem;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .footer-container {
    flex-direction: column;
    align-items: flex-start;
  }
  .footer-links {
    gap: 0.5rem 1.25rem;
  }
}

/* =====================================================================
   Sub-pages: case studies, notes, 404
   ===================================================================== */
.page {
  padding: calc(var(--nav-height) + 3rem) 0 4rem;
  min-height: 70vh;
}
.page-container {
  max-width: 820px;
}
.page-wide {
  max-width: 1040px;
}
.crumbs {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 1.25rem;
}
.crumbs a {
  color: var(--ink-soft);
}
.crumbs a:hover {
  color: var(--accent);
}
.page-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.8rem, 4.2vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-wrap: balance;
}
.page-lede {
  margin-top: 1rem;
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 62ch;
}
.page-meta {
  display: grid;
  gap: 0.6rem;
  margin: 1.75rem 0 0;
  padding: 1.1rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.page-meta div {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 0.75rem;
  font-size: 0.92rem;
  line-height: 1.5;
}
.page-meta dt {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding-top: 0.15rem;
}
.page-meta dd {
  color: var(--ink);
  overflow-wrap: anywhere;
}
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.shots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 2.25rem 0 0;
}
.shots figure {
  margin: 0;
}
.shots img,
.shots video {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--paper-2);
}
.shots figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.shots .shot-wide {
  grid-column: 1 / -1;
}

.prose {
  margin-top: 2.5rem;
  color: var(--ink-soft);
  font-size: 1.03rem;
  line-height: 1.7;
}
.prose > * + * {
  margin-top: 1rem;
}
.prose h2 {
  margin-top: 2.5rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.prose h3 {
  margin-top: 1.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}
.prose p,
.prose li {
  max-width: 68ch;
}
.prose strong {
  color: var(--ink);
  font-weight: 600;
}
.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.prose ul,
.prose ol {
  padding-left: 1.25rem;
}
.prose ul {
  list-style: disc;
}
.prose ol {
  list-style: decimal;
}
.prose li + li {
  margin-top: 0.45rem;
}
.prose li::marker {
  color: var(--accent);
}
.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.08em 0.35em;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.prose pre {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--ink);
}
.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  overflow-wrap: normal;
}
.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}
.prose .table-wrap {
  overflow-x: auto;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.prose th,
.prose td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.prose th {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.page-pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}
.page-pager a {
  color: var(--ink-soft);
  font-weight: 600;
}
.page-pager a:hover {
  color: var(--accent);
}

/* Lists of case studies and notes */
.entry-list {
  display: grid;
  gap: 1rem;
  margin-top: 2.5rem;
}
.entry-list-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.entry-card {
  display: block;
  padding: 1.35rem 1.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}
.entry-card:hover {
  border-color: var(--line-strong);
  background: var(--card-hover);
  transform: translateY(-2px);
}
.entry-card-kicker {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.entry-card h2 {
  margin-top: 0.45rem;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  text-wrap: balance;
}
.entry-card p {
  margin-top: 0.45rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.notfound {
  text-align: center;
  padding-top: 3rem;
}
.notfound-code {
  font-family: var(--font-display);
  font-size: clamp(4rem, 16vw, 8rem);
  line-height: 1;
  color: var(--accent);
}
.notfound .page-lede {
  margin-left: auto;
  margin-right: auto;
}
.notfound .page-actions {
  justify-content: center;
}

@media (max-width: 760px) {
  .page {
    padding: calc(var(--nav-height) + 1.75rem) 0 3rem;
  }
  .shots,
  .entry-list-2 {
    grid-template-columns: 1fr;
  }
  .page-meta div {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
  .prose {
    font-size: 1rem;
  }
  .prose pre {
    font-size: 0.75rem;
    padding: 0.9rem 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .entry-card,
  .entry-card:hover {
    transition: none;
    transform: none;
  }
}

/* ---------- Projects: "show all" on phones, card padding on the timeline ---------- */
.projects-more {
  display: none;
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.9rem 1rem;
  min-height: 48px;
  font: inherit;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.projects-more:focus-visible {
  outline: 2px solid var(--accent-coral);
  outline-offset: 2px;
}
.timeline-content {
  padding: 1.1rem 1.25rem;
}
.copy-field {
  gap: 0.5rem;
}
.copy-text {
  min-width: 0;
  overflow-wrap: anywhere;
}
.copy-btn {
  flex-shrink: 0;
}

/* ---- Modern web platform pass (Modern Web Guidance) ---- */

/* The browser's own UI (scrollbars, inputs, autofill) follows the site's theme. */
:root { color-scheme: light dark; }
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

/* Nav: the browser tracks which section is on screen (where supported) */
.nav-menu { scroll-target-group: auto; }
/* a jump to a section moves focus there for keyboards; no ring around a whole section */
section[tabindex="-1"]:focus { outline: none; }

/* Phone menu: a native popover (script sets popover="auto" below 860px) */
@media (max-width: 860px) {
  .nav-menu[popover] {
    position: fixed;
    inset: auto 0 auto 0;
    top: var(--nav-height);
    margin: 0;
    width: auto;
    max-height: calc(100dvh - var(--nav-height));
    overflow: auto;
    border: 0;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: inherit;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    overscroll-behavior: contain;
  }
  .nav-menu[popover]:is(:popover-open, .\:popover-open) {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
  }
  .nav-menu[popover]::backdrop { background: rgba(0, 0, 0, 0.25); }
  @media (prefers-reduced-motion: no-preference) {
    .nav-menu[popover] {
      transition: opacity 0.2s ease, translate 0.2s ease, display 0.2s, overlay 0.2s;
      transition-behavior: allow-discrete;
    }
    .nav-menu[popover]:not(:popover-open) { opacity: 0; translate: 0 -8px; }
    @starting-style { .nav-menu[popover]:popover-open { opacity: 0; translate: 0 -8px; } }
  }
}

/* Contact form: an error only after the visitor has finished with a field, not while typing */
.contact-form :is(input, textarea):user-invalid {
  border-color: #e5484d;
  box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.18);
}
.contact-form :is(input, textarea):user-valid { border-color: rgba(52, 199, 89, 0.55); }

/* Headlines wrap evenly, paragraphs avoid a lone last word */
h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }
