/* Palette and type from project_m/ARCHITECTURE.md.
   Contrast rule: cream + carbon/graphite carry all body text. Orange and lavender are
   accents only — never small text on cream. Orange text is fine on carbon (dark mode). */
:root {
  --carbon: #242423;
  --graphite: #333533;
  --cream: #FFEEDB;
  --lavender: #926D9C;
  --orange: #F26419;

  --bg: var(--cream);
  --surface: #FFF7EE;
  --ink: var(--carbon);
  --ink-2: var(--graphite);
  --muted: #5B5852;
  --line: rgba(36, 36, 35, .14);
  --line-strong: rgba(36, 36, 35, .3);
  --accent-text: var(--carbon);       /* links stay dark on cream; orange goes in the underline */
  --rule: rgba(146, 109, 156, .22);   /* notebook ruling */
  --shadow: 0 1px 0 rgba(36,36,35,.06), 0 12px 32px -12px rgba(36,36,35,.25);

  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --body: "Work Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, Menlo, monospace;
  --hand: "Caveat", "Bradley Hand", cursive;

  --shell: 1120px;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--carbon);
    --surface: #2C2D2B;
    --ink: var(--cream);
    --ink-2: #EBDCCB;
    --muted: #BDB0A1;
    --line: rgba(255, 238, 219, .13);
    --line-strong: rgba(255, 238, 219, .3);
    --accent-text: var(--orange);
    --rule: rgba(146, 109, 156, .28);
    --shadow: 0 1px 0 rgba(0,0,0,.2), 0 16px 40px -14px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: var(--carbon);
  --surface: #2C2D2B;
  --ink: var(--cream);
  --ink-2: #EBDCCB;
  --muted: #BDB0A1;
  --line: rgba(255, 238, 219, .13);
  --line-strong: rgba(255, 238, 219, .3);
  --accent-text: var(--orange);
  --rule: rgba(146, 109, 156, .28);
  --shadow: 0 1px 0 rgba(0,0,0,.2), 0 16px 40px -14px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.6 var(--body);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { font-family: var(--display); font-variation-settings: "SOFT" 100; margin: 0; color: var(--ink); }
p { margin: 0; }
a { color: var(--accent-text); text-decoration: underline; text-decoration-color: var(--orange); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 3px; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; border-radius: 4px; }
mark { background: none; color: inherit; }

.shell { width: 100%; max-width: var(--shell); margin-inline: auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)); }
@media (min-width: 720px) { .shell { padding-inline: 32px; } }

.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--orange); color: var(--carbon); padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.skip:focus { left: 8px; }

.eyebrow { font: 400 13px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.note { font: 600 22px/1.1 var(--hand); color: var(--lavender); }

/* ───────── Nav ───────── */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); margin-right: auto; }
/* Logo: paper plane leaving an app tile (assets/logo.svg). Tile flips with the theme. */
.brand-mark { width: 38px; height: 38px; flex: none; }
.bm-tile { fill: var(--ink); }
.bm-trail { stroke: var(--bg); }
.brand-name { font: 600 17px/1 var(--display); }
.nav ul { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; }
.nav li a { display: block; padding: 8px 12px; border-radius: 8px; font: 400 13px/1 var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--ink); text-decoration: none; }
.nav li a:hover { background: var(--line); }
/* Theme toggle lives in the footer; the icon and label show the mode you'd switch to. */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--ink);
  font: 400 12px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
}
.theme-toggle:hover { background: var(--line); }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}
@media (max-width: 719px) {
  .nav-inner { height: 56px; gap: 8px; }
  .brand-name { display: none; }
  .nav ul { gap: 0; }
  .nav li a { padding: 8px 7px; font-size: 11px; letter-spacing: .02em; }
}

/* ───────── Buttons ───────── */
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 12px 22px;
  border-radius: 999px; font: 600 16px/1.2 var(--body); text-decoration: none; transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--orange); color: var(--carbon); box-shadow: 0 3px 0 var(--carbon); }
.btn-primary:hover { box-shadow: 0 5px 0 var(--carbon); }
.btn-ghost { border: 1.5px solid var(--ink); color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--bg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { box-shadow: 0 3px 0 #000; } }
:root[data-theme="dark"] .btn-primary { box-shadow: 0 3px 0 #000; }

/* ───────── Hero ───────── */
.hero {
  display: grid; gap: 48px; align-items: center;
  padding-top: clamp(48px, 9vw, 104px); padding-bottom: 56px;
}
@media (min-width: 900px) { .hero { grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); } }
.hero h1 {
  font-size: clamp(40px, 6vw, 68px); line-height: 1.04; font-weight: 600; letter-spacing: -.02em;
  margin: 14px 0 24px; text-wrap: balance;
}
.lede { font-size: clamp(17px, 1.6vw, 19px); color: var(--ink-2); max-width: 56ch; margin-top: 24px; }
.lede strong { font-weight: 600; color: var(--ink); }

/* Notebook-edit role line. Default (no JS / reduced motion) = the finished state. */
.roles {
  font: 400 italic clamp(22px, 3vw, 30px)/1.5 var(--display);
  font-variation-settings: "SOFT" 100;
  color: var(--ink-2);
  padding: 4px 0;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(1.5em - 1px), var(--rule) calc(1.5em - 1px), var(--rule) 1.5em);
}
.role { position: relative; display: inline-block; white-space: nowrap; margin-right: .3em; }
.r1, .r2 { color: var(--muted); }
/* Hand-drawn strike: a slightly tilted, uneven stroke */
.r1::after, .r2::after {
  content: ""; position: absolute; left: -3%; right: -3%; top: 54%; height: .11em; border-radius: 1em;
  background: var(--ink); transform: rotate(-2deg); transform-origin: left center;
  clip-path: inset(0 0 0 0);
}
.r2::after { transform: rotate(1.5deg); }
.r3 { font-style: normal; font-weight: 600; color: var(--carbon); }
.r3 mark {
  position: relative; padding: 0 .2em; color: var(--carbon);
  background: linear-gradient(104deg, transparent .2em, var(--orange) .25em, var(--orange) calc(100% - .3em), transparent calc(100% - .2em));
  background-size: 100% 78%; background-position: 0 70%; background-repeat: no-repeat;
  border-radius: .25em .5em .3em .6em;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
@media (max-width: 600px) { .role { white-space: normal; } }

/* Animated states — only when script.js adds .animate (and motion is allowed) */
.roles.animate .role { clip-path: inset(0 100% 0 0); }
.roles.animate .role.written { clip-path: inset(0 -10% 0 0); transition: clip-path .9s cubic-bezier(.45,.05,.4,1); }
.roles.animate .r1::after, .roles.animate .r2::after { clip-path: inset(0 100% 0 0); }
.roles.animate .role.struck::after { clip-path: inset(0 0 0 0); transition: clip-path .35s ease-in; }
.roles.animate .r1, .roles.animate .r2 { color: var(--ink-2); transition: color .4s; }
.roles.animate .r1.struck, .roles.animate .r2.struck { color: var(--muted); }
.roles.animate .r3 mark { background-size: 0% 78%; transition: background-size .6s cubic-bezier(.3,.1,.3,1) .5s; }
.roles.animate .r3.written mark { background-size: 100% 78%; }

/* Phone mock-up */
.hero-phone { position: relative; justify-self: center; padding-bottom: 8px; }
.phone {
  width: min(280px, 72vw); aspect-ratio: 9 / 18.5; border-radius: 44px; padding: 11px;
  background: var(--carbon); box-shadow: var(--shadow), inset 0 0 0 2px #3b3c3a;
  position: relative; transform: rotate(3deg);
}
.phone-notch { position: absolute; top: 20px; left: 50%; width: 76px; height: 22px; margin-left: -38px; border-radius: 12px; background: #000; z-index: 2; }
.phone-screen {
  height: 100%; border-radius: 34px; overflow: hidden; position: relative;
  background:
    radial-gradient(120% 70% at 100% 0%, rgba(242,100,25,.55), transparent 60%),
    radial-gradient(90% 60% at 0% 100%, rgba(146,109,156,.75), transparent 65%),
    #3a3330;
  color: #FFEEDB; padding: 14px 16px 0; display: flex; flex-direction: column;
}
.phone-status { display: flex; justify-content: space-between; font: 700 12px/1 var(--body); padding: 4px 8px 0; letter-spacing: .02em; }
.phone-status span:last-child { font-size: 8px; letter-spacing: 1px; }
.phone-widget {
  margin-top: 34px; padding: 12px 14px; border-radius: 18px; background: rgba(255,238,219,.14);
  backdrop-filter: blur(6px); display: grid; gap: 4px;
}
.w-label { font: 400 9px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.w-title { font: 600 16px/1.2 var(--display); }
.w-bar { height: 5px; border-radius: 3px; background: rgba(255,238,219,.22); overflow: hidden; margin-top: 4px; }
.w-bar i { display: block; height: 100%; width: 72%; background: var(--orange); border-radius: inherit; }
.app-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 8px; margin-top: 20px; }
.app { display: grid; justify-items: center; gap: 5px; font: 500 9.5px/1.1 var(--body); text-align: center; color: #FFEEDB; }
.icon {
  width: 50px; height: 50px; border-radius: 13px; display: grid; place-items: center;
  font: 700 20px/1 var(--display); box-shadow: 0 4px 10px rgba(0,0,0,.25);
}
.icon-gfa { background: linear-gradient(140deg, #5c2a6e, #9b3a70); color: #ffd36b; }
.icon-m { background: linear-gradient(160deg, #f4f1ea, #d9d2c3); color: #3b5b8c; font-size: 24px; }
.icon-folder { background: rgba(255,238,219,.22); grid-template-columns: 1fr 1fr; gap: 4px; padding: 9px; }
.icon-folder i { width: 100%; height: 100%; border-radius: 4px; background: rgba(255,238,219,.75); }
.icon-folder i:nth-child(1) { background: var(--orange); }
.icon-folder i:nth-child(4) { background: var(--lavender); }
.icon-cf { background: #FFEEDB; color: var(--carbon); font: 700 15px/1 var(--mono); }
.icon-next { background: transparent; border: 2px dashed rgba(255,238,219,.6); box-shadow: none; font: 400 26px/1 var(--body); color: rgba(255,238,219,.8); }
.phone-dock {
  margin-top: auto; margin-bottom: 12px; padding: 10px; border-radius: 22px; background: rgba(255,238,219,.16);
  display: flex; justify-content: space-around;
}
.phone-dock .icon { width: 42px; height: 42px; border-radius: 11px; font-size: 16px; }
.icon-dart { background: #0b5f99; color: #6fd3f5; }
.icon-flutter { background: #e8f4fd; color: #0468d7; font-family: var(--body); }
.icon-code { background: var(--carbon); color: var(--orange); font: 700 13px/1 var(--mono); }
.note-phone { position: absolute; top: 0; right: -8px; transform: rotate(5deg); text-align: right; white-space: nowrap; }
@media (min-width: 900px) { .hero-phone { padding-top: 64px; } }
@media (max-width: 899px) { .note-phone { display: none; } }

/* ───────── Facts ───────── */
.facts dl {
  display: grid; grid-template-columns: repeat(2, 1fr); margin: 0;
  border-top: 1.5px solid var(--ink); border-bottom: 1px solid var(--line);
}
@media (min-width: 720px) { .facts dl { grid-template-columns: repeat(4, 1fr); } }
.facts dl > div { padding: 20px 16px 22px 0; display: flex; flex-direction: column-reverse; gap: 4px; }
.facts dl > div + div { padding-left: 16px; border-left: 1px solid var(--line); }
@media (max-width: 719px) {
  .facts dl > div:nth-child(3) { padding-left: 0; border-left: 0; }
  .facts dl > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
.facts dt { font: 400 12px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.facts dd { margin: 0; font: 600 clamp(30px, 4vw, 44px)/1 var(--display); letter-spacing: -.01em; }

/* ───────── Sections ───────── */
.section { padding-block: clamp(72px, 10vw, 120px) 0; }
.section-head { margin-bottom: 40px; max-width: 700px; }
.section h2 { font-size: clamp(34px, 5vw, 54px); line-height: 1.05; font-weight: 600; letter-spacing: -.015em; margin-top: 10px; text-wrap: balance; }
.section-lede { color: var(--ink-2); margin-top: 16px; font-size: 18px; max-width: 60ch; }

/* Projects */
.projects { display: grid; gap: 28px; }
@media (min-width: 860px) { .projects { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.project {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
  transition: transform .2s ease;
}
.project:hover { transform: translateY(-4px); }
.shot { display: block; background: var(--line); border-bottom: 1px solid var(--line); text-decoration: none; }
.shot-bar { display: flex; align-items: center; gap: 6px; padding: 9px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.shot-bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.shot-bar span {
  margin-left: 10px; flex: 1; padding: 3px 10px; border-radius: 6px; background: var(--line);
  font: 400 11px/1.4 var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.shot img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: top; }
.project-body { padding: 24px 24px 28px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.meta { font: 400 12px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.live { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 999px; background: var(--orange); color: var(--carbon); font-weight: 700; }
.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--carbon); }
.project h3 { font-size: 30px; line-height: 1.1; font-weight: 600; }
.project p:not(.meta):not(.note) { color: var(--ink-2); }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 4px 0 0; }
.tags li { font: 400 12px/1 var(--mono); padding: 6px 9px; border-radius: 6px; border: 1px solid var(--lavender); color: var(--ink-2); }
.wins { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 10px; }
.wins li { position: relative; padding-left: 22px; color: var(--ink-2); font-size: 16px; line-height: 1.5; }
.wins li::before { content: ""; position: absolute; left: 2px; top: .5em; width: 9px; height: 9px; border-radius: 2px; background: var(--orange); transform: rotate(45deg); }
.wins strong { color: var(--ink); font-weight: 600; }
.link { margin-top: auto; padding-top: 8px; font-weight: 600; align-self: flex-start; }
.project-next {
  background: transparent; box-shadow: none; border: 2px dashed var(--line-strong);
  grid-column: 1 / -1;
}
.project-next:hover { transform: none; }
.next-inner { padding: 32px 28px; display: grid; gap: 10px; max-width: 640px; }
.next-inner .note { margin-top: 4px; }

/* Toolbox */
.tools { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
@media (min-width: 720px) { .tools { grid-template-columns: repeat(5, 1fr); border-top: 0; } }
.tools li { padding: 18px 0; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
@media (min-width: 720px) {
  .tools li { padding: 0 18px 0 18px; border-bottom: 0; border-left: 1px solid var(--line); }
  .tools li:first-child { border-left: 3px solid var(--orange); }
}
.tools strong { font: 600 19px/1.2 var(--display); }
.tools span { color: var(--muted); font-size: 15px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; max-width: 860px; }
.timeline li { display: grid; gap: 4px 32px; padding: 22px 0; border-top: 1px solid var(--line); }
@media (min-width: 720px) { .timeline li { grid-template-columns: 150px 1fr; } }
.timeline .when, .receipts .when { font: 400 13px/1.6 var(--mono); color: var(--muted); padding-top: 4px; }
.timeline h3 { font-size: 22px; font-weight: 600; line-height: 1.25; }
.timeline p { color: var(--ink-2); margin-top: 4px; }

/* Teaching — given real weight, per the project_m brief */
.teaching { margin-top: clamp(72px, 10vw, 120px); padding-bottom: clamp(72px, 10vw, 120px); background: var(--carbon); color: var(--cream); }
.teaching .eyebrow { color: #BDB0A1; }
.teaching h2 { color: var(--cream); }
.teaching h2::after { content: ""; display: block; width: 72px; height: 6px; margin-top: 20px; border-radius: 3px; background: var(--orange); }
.teaching-cols { display: grid; gap: 40px; }
@media (min-width: 900px) { .teaching-cols { grid-template-columns: 1fr 1fr; gap: 64px; } }
.teaching .prose p { font: 400 clamp(20px, 2vw, 24px)/1.5 var(--display); font-variation-settings: "SOFT" 100; }
.teaching .prose p + p { margin-top: 18px; color: #EBDCCB; }
.receipts { list-style: none; margin: 0; padding: 0; }
.receipts li { padding: 16px 0; border-top: 1px solid rgba(255,238,219,.15); color: #EBDCCB; display: grid; gap: 2px; }
.receipts li:last-child { border-bottom: 1px solid rgba(255,238,219,.15); }
.receipts strong { color: var(--cream); font-weight: 600; }
.receipts .when { color: var(--orange); padding-top: 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .teaching { background: #1A1A19; } }
:root[data-theme="dark"] .teaching { background: #1A1A19; }

/* Contact */
.contact { padding-bottom: clamp(72px, 10vw, 120px); }
.contact h2 { font-size: clamp(40px, 7vw, 76px); max-width: 14ch; margin-bottom: 8px; }
.hl {
  padding: 0 .15em; color: var(--carbon);
  background: linear-gradient(100deg, transparent .1em, var(--orange) .15em, var(--orange) calc(100% - .15em), transparent calc(100% - .1em));
  background-size: 100% 70%; background-position: 0 75%; background-repeat: no-repeat;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.contact .btn-primary { word-break: break-all; }

/* Footer */
.footer { border-top: 1px solid var(--line); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 16px; padding-block: 28px calc(28px + env(safe-area-inset-bottom, 0px)); font: 400 13px/1.4 var(--mono); color: var(--muted); }

/* Scroll reveal (only when JS opts in) */
.reveal-ready .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s ease; }
.reveal-ready .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .btn:hover, .project:hover { transform: none; }
}
