/* ==========================================================
   paper + ink theme
   ========================================================== */
:root {
  --paper: #ebe5d6;
  --paper-2: #f3eee2;
  --card: #f8f4ea;
  --ink: #26221d;
  --ink-2: #5b544a;
  --ink-3: #8c8475;
  --rule: #d4ccb8;
  --red: #b23a2b;
  --green: #3f7d3a;
  --amber: #b8862b;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --hand: "Caveat", "Segoe Print", cursive;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.6;
  background-color: var(--paper);
  /* faint ruled lines + paper speckle */
  background-image:
    repeating-linear-gradient(to bottom, transparent 0 31px, rgba(120, 105, 80, .08) 31px 32px),
    radial-gradient(rgba(90, 70, 40, .06) 1px, transparent 1px),
    radial-gradient(rgba(90, 70, 40, .04) 1px, transparent 1px);
  background-size: 100% 32px, 7px 7px, 11px 11px;
  background-position: 0 0, 0 0, 3px 5px;
}
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

a { color: var(--ink); text-decoration-color: var(--red); text-underline-offset: 3px; }
a:hover { color: var(--red); }
strong { font-weight: 500; }

/* ===== Hero ===== */
.hero {
  max-width: 1120px; margin: 0 auto; min-height: 92vh;
  padding: 72px clamp(20px, 5vw, 56px) 40px;
  display: grid; grid-template-columns: 1.25fr 1fr; gap: 32px; align-items: center;
}
.name {
  font-weight: 400; letter-spacing: -.035em; line-height: .95; margin: 0;
  font-size: clamp(56px, 9vw, 124px);
}
.tagline { font-size: 13px; color: var(--ink-2); margin: 18px 0 22px; letter-spacing: .02em; }
.nav { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 13px; }
.nav a { text-decoration: none; border-bottom: 1px solid var(--ink-3); padding-bottom: 1px; }
.nav a:hover { border-color: var(--red); }
.hero-status { margin-top: 34px; font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.led { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(63,125,58,.15); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(63,125,58,0); } }

.rack { margin: 0; justify-self: end; font-size: 13px; line-height: 1.35; color: var(--ink-3); }
.rack b { font-weight: 500; color: var(--ink-2); }
.rack .led-a, .rack .led-b, .rack .led-c { animation: flick 1.4s steps(1) infinite; }
.rack .led-a { color: var(--green); }
.rack .led-b { color: var(--green); animation-delay: .5s; }
.rack .led-c { color: var(--amber); animation-delay: .9s; animation-duration: .8s; }
@keyframes flick { 50% { opacity: .25; } }

/* ===== Sections ===== */
main { max-width: 900px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 40px); }
.section { padding: 72px 0 8px; border-top: 1px solid var(--rule); }
.sec-h { font-weight: 400; font-size: clamp(32px, 4.4vw, 46px); letter-spacing: -.02em; line-height: 1.1; margin: 0 0 26px; display: flex; align-items: baseline; gap: 14px; }
.num { font-size: 13px; color: var(--red); letter-spacing: .05em; transform: translateY(-.6em); }
.mini-h { font-size: 12px; font-weight: 500; text-transform: lowercase; letter-spacing: .08em; color: var(--ink-2); margin: 40px 0 14px; }
.prose p { margin: 0 0 1em; }
.lead { color: var(--ink-2); margin: 0 0 28px; max-width: 680px; }

/* ===== About + polaroid ===== */
.about { display: grid; grid-template-columns: 250px 1fr; gap: 40px; align-items: start; }
.polaroid {
  margin: 8px 0 0; padding: 12px 12px 6px; background: #fffdf7; position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 10px 24px rgba(60,45,20,.16);
  transform: rotate(-2.5deg);
}
.polaroid::before, .polaroid::after {
  content: ""; position: absolute; top: -12px; width: 76px; height: 24px;
  background: rgba(232, 205, 140, .7); box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.polaroid::before { left: 18px; transform: rotate(-8deg); }
.polaroid::after { right: 18px; transform: rotate(7deg); }
.polaroid img {
  display: block; width: 100%; height: auto; aspect-ratio: 12 / 13; object-fit: cover;
  background: #d9d2c1; filter: saturate(.92) contrast(1.02);
}
.photo-ph { aspect-ratio: 12 / 13; background: #d9d2c1; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--ink-3); }
.polaroid figcaption { font-family: var(--hand); font-size: 24px; text-align: center; color: var(--ink-2); padding-top: 4px; }

/* ===== Project ===== */
.path {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--rule); padding: 22px; font-size: 13px;
}
.hop { flex: 1 1 0; min-width: 110px; display: flex; flex-direction: column; padding: 8px 12px; border: 1px solid var(--ink-3); background: var(--paper-2); }
.hop b { font-weight: 500; }
.hop small { color: var(--ink-3); font-size: 11px; }
.hop.hot { border-color: var(--red); }
.hop.hot b { color: var(--red); }
.arrow { color: var(--red); }
.watch { flex-basis: 100%; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--rule); color: var(--amber); font-size: 12px; }

.phases { list-style: none; margin: 0; padding: 0; }
.phase {
  display: grid; grid-template-columns: 44px 1fr auto; column-gap: 16px; align-items: baseline;
  padding: 14px 0; border-bottom: 1px solid var(--rule);
}
.phase-num { font-family: var(--mono); font-size: 12px; color: var(--ink-3); grid-row: span 2; }
.phase h4 { margin: 0; font-weight: 500; font-size: 19px; }
.phase p { margin: 2px 0 0; grid-column: 2 / 4; color: var(--ink-2); font-size: 16px; }
.badge { font-family: var(--mono); font-size: 11px; grid-column: 3; grid-row: 1; }
.badge.done { color: var(--green); }
.badge.done::before { content: "● "; }
.badge.progress { color: var(--amber); }
.badge.progress::before { content: "◐ "; }
.badge.live { color: var(--red); }
.badge.live::before { content: "◉ "; }

/* ===== BradBot ===== */
.bot-wrap { display: grid; grid-template-columns: 1.55fr 1fr; gap: 28px; align-items: start; }
.chat { background: var(--card); border: 1px solid var(--ink-3); display: flex; flex-direction: column; box-shadow: 4px 4px 0 var(--rule); }
.chat-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--rule); font-size: 12px; color: var(--ink-2); }
.status { display: inline-flex; align-items: center; gap: 6px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.status.online .status-dot { background: var(--green); }
.status.offline .status-dot { background: var(--amber); }
.chat-log { height: 360px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; font-size: 17px; }
.msg { max-width: 88%; white-space: pre-wrap; word-wrap: break-word; line-height: 1.5; }
.msg::before { display: block; font-family: var(--mono); font-size: 11px; margin-bottom: 2px; }
.msg.user { align-self: flex-end; text-align: right; }
.msg.user::before { content: "you"; color: var(--ink-3); }
.msg.bot::before { content: "bradbot"; color: var(--red); }
.msg.error { color: var(--red); }
.msg .tag { display: block; font-family: var(--mono); font-size: 10.5px; color: var(--amber); }
.typing::before { content: "bradbot is thinking" !important; color: var(--ink-3) !important; }
.typing span { display: inline-block; width: 5px; height: 5px; margin-right: 4px; border-radius: 50%; background: var(--ink-3); animation: flick 1s steps(1) infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 12px; }
.chip { font-family: var(--serif); font-size: 14px; color: var(--ink-2); background: transparent; border: 1px solid var(--rule); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.chip:hover { border-color: var(--red); color: var(--red); }
.chat-form { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--rule); }
.chat-form input { flex: 1; min-width: 0; font-family: var(--serif); font-size: 17px; color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--ink-3); padding: 6px 2px; }
.chat-form input:focus { outline: none; border-color: var(--red); }
.counter { font-size: 11px; color: var(--ink-3); }
.send { font-size: 12px; background: var(--ink); color: var(--paper-2); border: 0; padding: 8px 14px; cursor: pointer; }
.send:hover { background: var(--red); }
.send:disabled { opacity: .5; cursor: not-allowed; }

.defences .mini-h { margin-top: 0; }
.mono-list { margin: 0; padding-left: 20px; font-size: 15.5px; color: var(--ink-2); }
.mono-list li { margin-bottom: 9px; }
.mono-list li::marker { font-family: var(--mono); font-size: 11px; color: var(--red); }
.mono-list b { font-weight: 500; color: var(--ink); }
.aside-note { font-size: 14px; color: var(--ink-3); font-style: italic; border-top: 1px dashed var(--rule); padding-top: 10px; }

/* ===== Fun facts ===== */
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.fact { background: var(--card); border: 1px solid var(--rule); padding: 16px; transition: transform .2s; }
.fact:nth-child(odd) { transform: rotate(-.6deg); }
.fact:nth-child(even) { transform: rotate(.5deg); }
.fact:hover { transform: rotate(0) translateY(-3px); }
.fact-ico { font-size: 11px; color: var(--red); }
.fact p { margin: 6px 0 0; font-size: 16.5px; line-height: 1.45; }
.fact-img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; margin-top: 8px; background: #d9d2c1; filter: saturate(.92) contrast(1.02); }

/* ===== Toolkit ===== */
.tk-row { display: grid; grid-template-columns: 190px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); font-size: 17px; }
.tk-label { font-size: 12px; color: var(--ink-3); padding-top: 4px; }
.certs { list-style: none; padding: 0; margin: 0; }
.certs li { padding: 8px 0; border-bottom: 1px dotted var(--rule); }
.yr { display: inline-block; width: 70px; font-size: 12px; color: var(--red); }

/* ===== Contact & footer ===== */
.links { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 10px 26px; font-size: 14px; }
.footer { max-width: 900px; margin: 80px auto 0; padding: 24px clamp(20px, 5vw, 40px) 40px; border-top: 1px solid var(--rule); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 11.5px; color: var(--ink-3); }
.footer a { color: var(--ink-3); }

/* ===== Reveal ===== */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .8s ease, transform .8s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; min-height: auto; padding-top: 56px; }
  .rack { justify-self: start; font-size: 11px; }
  .about, .bot-wrap { grid-template-columns: 1fr; }
  .polaroid { width: 230px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .tk-row { grid-template-columns: 1fr; gap: 2px; }
}
@media (max-width: 520px) {
  .facts { grid-template-columns: 1fr; }
  .rack { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .led, .rack span, .typing span { animation: none; }
}
