/* ============================================================
   codyhurst.com — main site styles
   Design system: navy + gold, deeper palette aligned with logo.
   Structure:
     1. Tokens (light + dark)
     2. Reset + base
     3. Accessibility primitives (skip link, visually hidden, focus)
     4. Header (brand, nav, theme toggle, announcements)
     5. Hero
     6. Sections, prose, page TOC
     7. Project cards + tech tags
     8. Latest lists (blog/forum)
     9. Buttons + CTA
    10. Footer
    11. Reduced motion + print
   ============================================================ */

/* 1. Tokens -------------------------------------------------------- */
:root {
  color-scheme: light;

  /* Brand (shared across all codyhurst sites in spirit; main = navy) */
  --brand-primary:        #0f2744;   /* deep navy from logo */
  --brand-primary-hover:  #173a66;
  --brand-accent:         #c9a04a;   /* muted gold from logo */
  --brand-accent-strong:  #b48a30;

  /* Neutrals */
  --bg:          #f6f6f4;
  --surface:     #ffffff;
  --surface-alt: #f0efea;
  --border:      #d9d6cf;
  --text:        #1a1f2b;
  --text-muted:  #525a6b;
  --link:        var(--brand-primary);
  --link-hover:  var(--brand-primary-hover);

  /* Status */
  --error:   #9a1b2e;
  --success: #0b6b3a;

  /* Type */
  --font-sans: 'Inter', 'Open Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Inter', 'Open Sans', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Scale */
  --step--1: clamp(0.875rem, 0.84rem + 0.18vw, 0.95rem);
  --step-0:  clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --step-1:  clamp(1.15rem, 1.08rem + 0.35vw, 1.35rem);
  --step-2:  clamp(1.35rem, 1.2rem + 0.75vw, 1.75rem);
  --step-3:  clamp(1.75rem, 1.45rem + 1.5vw, 2.5rem);
  --step-4:  clamp(2.25rem, 1.8rem + 2.25vw, 3.5rem);
  --step-5:  clamp(2.75rem, 2.1rem + 3.25vw, 4.5rem);

  /* Layout */
  --container: 68rem;
  --gap:       1.25rem;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 10px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.06);

  /* Motion */
  --t-fast: 160ms ease;
  --t:      240ms ease;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg:          #0b1220;
  --surface:     #121a2a;
  --surface-alt: #182339;
  --border:      #2a3655;
  --text:        #e8ecf3;
  --text-muted:  #9aa4bb;
  --link:        #e7c774;
  --link-hover:  #fadb8f;
  --brand-accent: #e0be6b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 6px 14px rgba(0,0,0,0.5), 0 2px 4px rgba(0,0,0,0.4);
}

/* 2. Reset + base -------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { font-size: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0 0 0.5em;
  color: var(--text);
}

p { margin: 0 0 1em; }

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: color var(--t-fast);
}
a:hover, a:focus-visible { color: var(--link-hover); }

ul { margin: 0; padding: 0; }

code, pre { font-family: var(--font-mono); }

/* 3. Accessibility primitives ------------------------------------- */
.skip-link {
  position: absolute;
  top: -40px; left: 0;
  background: var(--brand-primary);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 1000;
  text-decoration: none;
  border-radius: 0 0 var(--radius) 0;
  transition: top var(--t-fast);
}
.skip-link:focus { top: 0; }

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

:focus-visible {
  outline: 3px solid var(--brand-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 4. Header -------------------------------------------------------- */
.site-header {
  background: linear-gradient(180deg, var(--brand-primary), var(--brand-primary-hover));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.site-header a { color: #fff; text-decoration: none; }

.site-header__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand__logo {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #fff;
}
.brand__name { font-weight: 700; font-size: var(--step-1); letter-spacing: 0.01em; }

.primary-nav { margin-left: auto; }
.primary-nav ul {
  list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem;
}
.primary-nav a {
  display: inline-block;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius);
  font-weight: 500;
  transition: background var(--t-fast);
}
.primary-nav a:hover, .primary-nav a:focus-visible {
  background: rgba(255,255,255,0.12);
}

.nav-toggle {
  display: none;
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.3);
  padding: 0.5rem 0.75rem; border-radius: var(--radius); cursor: pointer;
}
.nav-toggle__icon {
  display: inline-block; width: 20px; height: 2px; background: currentColor;
  position: relative;
}
.nav-toggle__icon::before,
.nav-toggle__icon::after {
  content: ''; position: absolute; left: 0; width: 100%; height: 2px; background: currentColor;
}
.nav-toggle__icon::before { top: -6px; }
.nav-toggle__icon::after  { top:  6px; }

.theme-toggle {
  background: transparent; color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 0.4rem 0.6rem; border-radius: var(--radius);
  cursor: pointer; font-size: 1rem; line-height: 1;
}
.theme-toggle:hover, .theme-toggle:focus-visible {
  background: rgba(255,255,255,0.12);
}

.announcements {
  background: var(--brand-accent);
  color: #1a1200;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
}
.announcements__content { flex: 1; text-align: center; }
.announcements__content :is(a) { color: #1a1200; }
.announcements__pause {
  background: rgba(0,0,0,0.1);
  color: inherit;
  border: 1px solid rgba(0,0,0,0.2);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: var(--step--1);
  cursor: pointer;
}
.announcements__pause:hover,
.announcements__pause:focus-visible { background: rgba(0,0,0,0.18); }

/* 5. Hero ---------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1200px 400px at 20% -10%, rgba(201,160,74,0.15), transparent 70%),
    linear-gradient(180deg, var(--surface-alt), var(--bg));
  border-bottom: 1px solid var(--border);
}
.hero__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(3rem, 6vw, 6rem) 1rem clamp(2.5rem, 5vw, 5rem);
  text-align: left;
}
.hero__inner--split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 3vw, 2.5rem);
  align-items: center;
}
.hero__content { min-width: 0; }
.hero__content .hero__title { max-inline-size: 22ch; }
.hero__portrait {
  margin: 0;
  justify-self: end;
  width: 100%;
  max-width: 26rem;
}
.hero__portrait img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.06),
    0 10px 30px -10px rgba(0,0,0,0.25);
  border: 1px solid var(--border);
}
@media (max-width: 720px) {
  .hero__inner--split {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .hero__portrait {
    order: -1;
    justify-self: center;
    max-width: 22rem;
  }
}
.hero__kicker {
  font-size: var(--step--1);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brand-accent-strong);
  margin: 0 0 0.75rem;
  font-weight: 600;
}
.hero__title {
  font-size: var(--step-5);
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 0 0 1.25rem;
}
.hero__title-line { display: block; }
.hero__title-line--accent { color: var(--brand-primary); }
[data-theme="dark"] .hero__title-line--accent { color: var(--brand-accent); }
.hero__tagline {
  font-size: var(--step-1);
  color: var(--text-muted);
  max-width: 42rem;
  margin: 0 0 2rem;
}
.hero__cta {
  display: flex; gap: 0.75rem; flex-wrap: wrap;
}

/* 6. Sections + prose + TOC --------------------------------------- */
main {
  outline: none;
}
.page-header {
  max-width: var(--container);
  margin: 2.5rem auto 1rem;
  padding: 0 1rem;
}
.page-header h1 {
  font-size: var(--step-4);
  margin: 0;
}
.section {
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(2.5rem, 4vw, 4.5rem) 1rem;
  border-top: 1px solid var(--border);
}
.section:first-of-type { border-top: 0; }
.section__title {
  font-size: var(--step-3);
  margin: 0 0 1.25rem;
  position: relative;
  padding-bottom: 0.5rem;
}
.section__title::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 3rem; height: 3px;
  background: var(--brand-accent);
  border-radius: 2px;
}

.prose { font-size: var(--step-0); }
.prose p { margin: 0 0 1em; }
.prose h3 { margin-top: 2rem; font-size: var(--step-2); }
.prose h4 { margin-top: 1.5rem; font-size: var(--step-1); }
.prose ul, .prose ol { padding-left: 1.25rem; margin: 0 0 1em; }
.prose li { margin-bottom: 0.35em; }
.prose a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--brand-accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.page-toc {
  max-width: var(--container);
  margin: 1.5rem auto 0;
  padding: 0 1rem;
}
.page-toc ul {
  list-style: none;
  display: flex; flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.page-toc a {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: var(--step--1);
  color: var(--text);
  text-decoration: none;
}
.page-toc a:hover, .page-toc a:focus-visible {
  background: var(--surface-alt);
  color: var(--brand-primary);
}
[data-theme="dark"] .page-toc a:hover,
[data-theme="dark"] .page-toc a:focus-visible {
  color: var(--brand-accent);
}

/* 7. Project cards ------------------------------------------------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1.25rem;
  list-style: none;
  padding: 0;
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.project-card:hover,
.project-card:focus-within {
  border-color: var(--brand-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.project-card__image {
  border-radius: var(--radius);
  margin: -0.25rem 0 1rem;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-alt);
}
.project-card__title {
  font-size: var(--step-2);
  margin: 0 0 0.5rem;
}
.project-card__summary {
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}
.project-card__meta {
  font-size: var(--step--1);
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}
.project-card__outcome {
  margin: 0.5rem 0 1rem;
}
.project-card__links {
  margin-top: auto;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.tech-tags {
  list-style: none;
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  margin: 0 0 0.75rem;
  padding: 0;
}
.tech-tag {
  font-size: var(--step--1);
  padding: 0.15rem 0.5rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
}

/* 7b. Application cards + gallery ---------------------------------- */
.section__lede {
  color: var(--text-muted);
  margin: -0.25rem 0 1.25rem;
  max-width: 48rem;
}
.app-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
}
.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}
.app-card__title {
  font-size: var(--step-2);
  margin: 0;
}
.app-card__summary {
  color: var(--text-muted);
  margin: 0;
}
.app-card__features {
  list-style: disc;
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.35rem;
  color: var(--text);
  font-size: var(--step--1);
}
.app-card__features li { margin: 0; }
.app-card__features kbd {
  font: inherit;
  font-size: 0.85em;
  padding: 0.05em 0.35em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-alt);
  color: var(--text);
}
.app-card__features code {
  font-size: 0.9em;
  padding: 0.05em 0.3em;
  border-radius: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.app-card__gallery {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}
.app-card__gallery a {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  line-height: 0;
  background: #0b0b0b;
  transition: transform var(--t), border-color var(--t), box-shadow var(--t);
}
.app-card__gallery a:hover,
.app-card__gallery a:focus-visible {
  border-color: var(--brand-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.app-card__gallery a:focus-visible {
  outline: 3px solid var(--brand-accent);
  outline-offset: 2px;
}
.app-card__gallery img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* 8. Latest lists -------------------------------------------------- */
.latest-list {
  list-style: none; padding: 0; margin: 0 0 1rem;
  display: grid;
  gap: 0.75rem;
}
.latest-list li {
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.latest-list a { font-weight: 600; }
.latest-list .excerpt {
  margin: 0.35rem 0 0; color: var(--text-muted); font-size: var(--step--1);
}

/* 9. Buttons ------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  border: 2px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.btn:focus-visible { outline: 3px solid var(--brand-accent); outline-offset: 3px; }
.btn--primary {
  background: var(--brand-primary);
  color: #fff;
}
.btn--primary:hover, .btn--primary:focus-visible {
  background: var(--brand-primary-hover);
  color: #fff;
  transform: translateY(-1px);
}
.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn--ghost:hover, .btn--ghost:focus-visible {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}
[data-theme="dark"] .btn--ghost:hover,
[data-theme="dark"] .btn--ghost:focus-visible {
  color: var(--brand-accent);
  border-color: var(--brand-accent);
}

/* 10. Footer ------------------------------------------------------- */
.site-footer {
  background: var(--brand-primary);
  color: #dde2ec;
  margin-top: 4rem;
}
.site-footer a { color: #fff; }
.site-footer__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 2.5rem 1rem;
  display: grid;
  gap: 1.5rem;
}
.site-footer__socials h2 {
  font-size: var(--step-1);
  color: #fff;
  margin-bottom: 0.75rem;
}
.social-links {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.social-links a {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.12);
}
.social-links a:hover, .social-links a:focus-visible {
  background: rgba(255,255,255,0.2);
}
.site-footer__copyright p {
  color: #b7c0d1; font-size: var(--step--1); margin: 0;
}

/* 11. Reduced motion + print + responsive ------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  html { scroll-behavior: auto; }
  .project-card:hover,
  .project-card:focus-within { transform: none; }
}

@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; order: 3; margin-left: auto; }
  .primary-nav {
    order: 4; width: 100%; margin: 0.5rem 0 0;
    max-height: 0; overflow: hidden;
    transition: max-height var(--t);
  }
  .primary-nav.is-open { max-height: 40rem; }
  .primary-nav ul { flex-direction: column; gap: 0.25rem; }
  .primary-nav a { display: block; width: 100%; }
}

@media print {
  .site-header, .site-footer, .announcements, .hero__cta, .nav-toggle, .theme-toggle,
  .page-toc { display: none; }
  body { background: #fff; color: #000; }
  .section, .hero { padding: 1rem 0; }
  a { color: #000; }
}

/* Donations list (crypto addresses) */
.donations {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem 1rem;
  margin: 1rem 0;
}
.donations dt {
  font-weight: 600;
  margin-top: 0.75rem;
}
.donations dd {
  margin: 0;
}
.donations dd code {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
  word-break: break-all;
  overflow-wrap: anywhere;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  background: rgba(127,127,127,0.12);
  user-select: all;
}
