/* ============================================================
   Peter Whelan — Anthropic-inspired Design System
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #e8e6dc;
  --bg-dark: #d9d7cd;
  --text-primary: #141413;
  --text-secondary: #30302e;
  --text-muted: rgba(20, 20, 19, 0.68);
  --accent: #9a6a00;
  --accent-soft: rgba(237, 161, 0, 0.15);
  --accent-rust: #b04a2a;
  --border: rgba(194, 192, 182, 0.3);
  --border-solid: #a09e94;
  --white: #faf9f0;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --site-margin: clamp(1.5rem, 1rem + 3vw, 5rem);
  --max-width: 1200px;
  --transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a {
  color: var(--text-primary);
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.2em;
  transition: opacity var(--transition);
}
a:hover {
  opacity: 0.7;
}

/* --- Focus styles (WCAG 2.4.7) --- */
:focus-visible {
  outline: 2px solid var(--accent-rust);
  outline-offset: 3px;
  border-radius: 3px;
}
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent-rust);
  outline-offset: 3px;
}
.nav-cta:focus-visible {
  outline-offset: 4px;
}

/* --- Skip to content (WCAG 2.4.1) --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--text-primary);
  color: var(--bg);
  padding: 0.75rem 1.5rem;
  border-radius: 0 0 8px 8px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 10000;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0;
}

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

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.5rem, 2rem + 3vw, 5rem);
}

h2 {
  font-size: clamp(1.8rem, 1.5rem + 1.5vw, 3rem);
  margin-bottom: 1.5rem;
}

h3 {
  font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.8rem);
  margin-bottom: 1rem;
}

h4 {
  font-size: 1.1rem;
  font-family: var(--font-sans);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

p {
  font-size: clamp(1rem, 0.95rem + 0.2vw, 1.125rem);
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  max-width: 680px;
}

blockquote {
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 1rem + 0.8vw, 1.6rem);
  font-style: italic;
  color: var(--text-primary);
  border-left: 3px solid var(--accent);
  padding-left: 1.5rem;
  margin: 2rem 0;
  max-width: 680px;
}

/* --- Layout --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--site-margin);
}

.section {
  padding: clamp(4rem, 3rem + 4vw, 8rem) 0;
}

.section + .section {
  border-top: 1px solid var(--border);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 1.5rem + 2vw, 4rem);
  align-items: start;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

@media (max-width: 768px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* --- Navigation --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4.25rem;
  background: rgba(232, 230, 220, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1000;
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--site-margin);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.nav-logo {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  text-decoration: none;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-secondary);
  transition: color var(--transition);
  position: relative;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text-primary);
  opacity: 1;
}

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--text-primary);
}

.nav-cta {
  background: var(--text-primary);
  color: var(--bg) !important;
  padding: 0.5rem 1.25rem;
  border-radius: 100px;
  font-size: 0.85rem !important;
  transition: transform var(--transition), opacity var(--transition) !important;
}
.nav-cta:hover {
  transform: scale(1.03);
  opacity: 1 !important;
}

/* Mobile Nav */
.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 4px;
  background: none;
  border: none;
}
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--text-primary);
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.nav-hamburger.open span:nth-child(1) {
  transform: rotate(45deg) translate(4px, 5px);
}
.nav-hamburger.open span:nth-child(2) {
  opacity: 0;
}
.nav-hamburger.open span:nth-child(3) {
  transform: rotate(-45deg) translate(4px, -5px);
}

@media (max-width: 768px) {
  .nav-hamburger { display: flex; }
  .nav-links {
    position: fixed;
    top: 4.25rem;
    left: 0;
    right: 0;
    bottom: 0;
    background: #e8e6dc;  /* solid — not var() — to guarantee opacity on all devices */
    z-index: 999;
    flex-direction: column;
    justify-content: flex-start;
    padding: 2rem var(--site-margin);
    gap: 1.5rem;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .nav-links.open {
    transform: translateX(0);
  }
  .nav-links a { font-size: 1.2rem; }
}

/* --- Hero --- */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding-top: 4.25rem;
}

.hero-content {
  max-width: 900px;
}

.hero h1 {
  margin-bottom: 1.5rem;
}

.hero h1 .word {
  display: inline-block;
  margin-right: 0.3em;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 1.3s cubic-bezier(0.16, 1, 0.3, 1),
              transform 1.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.hero h1 .word.visible {
  opacity: 1;
  transform: translateY(0);
}

.hero-subtitle {
  font-size: clamp(1.1rem, 1rem + 0.4vw, 1.35rem);
  color: var(--text-secondary);
  max-width: 620px;
  line-height: 1.7;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 1s ease 0.8s, transform 1s ease 0.8s;
}

.hero-subtitle.visible {
  opacity: 1;
  transform: translateY(0);
}

.hero-cta {
  margin-top: 2.5rem;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 1s ease 1.2s, transform 1s ease 1.2s;
}

.hero-cta.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.75rem;
  border-radius: 100px;
  font-size: 0.95rem;
  text-decoration: none;
  font-weight: 500;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--text-primary);
  color: var(--bg);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(20, 20, 19, 0.15);
  opacity: 1;
  color: var(--bg);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-solid);
}
.btn-secondary:hover {
  background: rgba(20, 20, 19, 0.04);
  opacity: 1;
}

.btn-arrow::after {
  content: '\2192';
  transition: transform var(--transition);
}
.btn-arrow:hover::after {
  transform: translateX(4px);
}

/* --- Stats Row --- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 2rem;
  padding: clamp(3rem, 2rem + 3vw, 5rem) 0;
}

.stat {
  text-align: left;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 2rem + 2vw, 4rem);
  font-weight: 400;
  line-height: 1;
  margin-bottom: 0.5rem;
  letter-spacing: -0.03em;
}

.stat-value .accent {
  color: var(--accent-rust);
}

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

/* --- Cards --- */
.card {
  background: rgba(250, 249, 240, 0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(20, 20, 19, 0.06);
}

.card h3 {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.card p {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* --- Blog / Article Cards --- */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

.article-card {
  display: block;
  text-decoration: none;
  background: rgba(250, 249, 240, 0.4);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.article-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(20, 20, 19, 0.08);
  background: rgba(250, 249, 240, 0.7);
  opacity: 1;
}

.article-card .meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.article-card h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.article-card .preview {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.article-card .category {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-rust);
  background: rgba(217, 119, 87, 0.08);
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  margin-top: 0.75rem;
}

/* --- The Rake Section --- */
.rake-story {
  max-width: 680px;
}

.rake-story p {
  margin-bottom: 1rem;
  line-height: 1.85;
}

.rake-story .dialogue {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.1em;
  color: var(--text-primary);
}

/* --- Contact --- */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: start;
}

.contact-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.contact-item .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.contact-item a {
  font-size: 1.1rem;
}

@media (max-width: 768px) {
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

/* --- Footer --- */
.footer {
  border-top: 1px solid var(--border);
  padding: 3rem 0;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-copy {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.footer-links a {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
}

/* --- Scroll Reveal --- */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Video Embed --- */
.video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin: 2rem 0;
}

.video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* --- Tag list --- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  transition: background var(--transition);
  cursor: pointer;
}

.tag:hover, .tag.active {
  background: rgba(20, 20, 19, 0.06);
  opacity: 1;
}

/* --- Highlight mark --- */
mark {
  background: var(--accent-soft);
  color: var(--text-primary);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

/* --- Divider --- */
.divider {
  height: 1px;
  background: var(--border);
  margin: 3rem 0;
}

/* --- Prefers reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .hero h1 .word {
    opacity: 1;
    transform: none;
  }
}

/* --- Page-specific hero (shorter) --- */
.hero-short {
  min-height: auto;
  padding-top: calc(4.25rem + 4rem);
  padding-bottom: 3rem;
}
