/* ===========================================================
   Michael Smith — sketchbook portfolio
   Two files, no framework. Edit freely.
   =========================================================== */

:root {
  /* paper */
  --paper:        #faf7f0;
  --paper-shade:  #f3eee2;
  --grid:         rgba(72, 94, 140, 0.085);
  --rule:         rgba(196, 84, 78, 0.32);
  --grain:        0.035;

  /* ink */
  --ink:          #2b2a26;
  --ink-soft:     #57534a;
  --ink-faint:    #8e887a;
  --pencil:       #3c5a8a;
  --tape:         rgba(206, 190, 145, 0.35);
  --marker:       rgba(255, 212, 88, 0.5);

  /* type */
  --hand: "Caveat", "Segoe Script", "Bradley Hand", cursive;
  --body: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --line: 28px;   /* notebook grid pitch */
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:        #17181b;
    --paper-shade:  #121316;
    --grid:         rgba(255, 255, 255, 0.045);
    --rule:         rgba(214, 118, 112, 0.28);
    --grain:        0.05;

    --ink:          #e9e5db;
    --ink-soft:     #b6b0a3;
    --ink-faint:    #837d71;
    --pencil:       #93b2e0;
    --tape:         rgba(255, 255, 255, 0.06);
    --marker:       rgba(147, 178, 224, 0.22);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--paper);

  /* faint grid, drawn twice so the paper reads as squared notebook stock */
  background-image:
    repeating-linear-gradient(to right,  var(--grid) 0 1px, transparent 1px var(--line)),
    repeating-linear-gradient(to bottom, var(--grid) 0 1px, transparent 1px var(--line));
}

/* Paper grain — a noise texture laid over everything, non-interactive. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--paper);
  color: var(--ink);
  padding: 0.6rem 1rem;
  border: 2px solid var(--ink);
  z-index: 10;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ----------------------------------------------------------
   The sheet
   ---------------------------------------------------------- */

.sheet {
  position: relative;
  z-index: 2;
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(2.5rem, 7vw, 5.5rem) clamp(1.25rem, 5vw, 3rem)
           clamp(3rem, 8vw, 6rem) clamp(2.75rem, 8vw, 6.5rem);
}

/* The red margin rule down the left edge. */
.sheet::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: clamp(1.5rem, 5.5vw, 4.25rem);
  width: 2px;
  background: var(--rule);
  filter: url(#rough-2);
}

/* ----------------------------------------------------------
   Masthead
   ---------------------------------------------------------- */

.masthead { margin-bottom: clamp(3rem, 7vw, 5rem); }

.name {
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(3.5rem, 11vw, 6.5rem);
  line-height: 0.95;
  margin: 0 0 0.15em;
  letter-spacing: 0.01em;
}

.sub {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-family: var(--hand);
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  color: var(--pencil);
  margin: 0 0 1.4rem;
}

.underline-sketch {
  position: relative;
  display: inline-block;
  padding-bottom: 0.12em;
}
.underline-sketch::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: 0;
  height: 3px;
  background: currentColor;
  border-radius: 2px;
  opacity: 0.55;
  filter: url(#rough-3);
}

.arrow {
  width: clamp(66px, 12vw, 104px);
  height: auto;
  color: var(--ink-faint);
  flex: none;
  /* Swung clockwise about the tail, so the end nearest the text stays put and
     only the tip drops. Bump the angle to tilt it further. */
  transform: rotate(18deg);
  transform-origin: 6% 84%;
  overflow: visible;
}
.arrow path {
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.blurb {
  max-width: 46ch;
  color: var(--ink-soft);
  margin: 0;
  font-size: 1.05rem;
}

/* ----------------------------------------------------------
   Section labels
   ---------------------------------------------------------- */

.section-label {
  font-family: var(--hand);
  font-weight: 600;
  font-size: clamp(1.9rem, 4.5vw, 2.6rem);
  color: var(--ink-faint);
  margin: 0 0 1.75rem;
  scroll-margin-top: 1.5rem;
}
.section-label::before {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 3px;
  margin-right: 0.55em;
  vertical-align: 0.28em;
  background: currentColor;
  opacity: 0.5;
  filter: url(#rough-1);
}

/* ----------------------------------------------------------
   Project cards
   ---------------------------------------------------------- */

.grid {
  list-style: none;
  margin: 0 0 clamp(3.5rem, 8vw, 5.5rem);
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: clamp(2rem, 4.5vw, 3.25rem);
}

.card {
  position: relative;
  padding: 2rem 1.75rem 1.6rem;
  background: var(--paper-shade);
  transition: transform 0.25s ease;
}

/* The hand-drawn box. Lives on a pseudo-element so the wobble filter
   never touches the text inside the card. */
.card::before {
  content: "";
  position: absolute;
  inset: -3px;
  border: 2.5px solid var(--ink);
  border-radius: 14px 9px 16px 10px;
  pointer-events: none;
  opacity: 0.85;
}
.card[data-rough="1"]::before { filter: url(#rough-1); }
.card[data-rough="2"]::before { filter: url(#rough-2); }
.card[data-rough="3"]::before { filter: url(#rough-3); }
.card[data-rough="4"]::before { filter: url(#rough-4); }

/* Every card sits on the page a little crooked, like it was taped down.
   Cycles every four, so the pad can grow without cards snapping straight. */
.card:nth-child(4n + 1) { transform: rotate(-0.7deg); }
.card:nth-child(4n + 2) { transform: rotate(0.6deg); }
.card:nth-child(4n + 3) { transform: rotate(0.45deg); }
.card:nth-child(4n + 4) { transform: rotate(-0.5deg); }

.card:hover,
.card:focus-within {
  transform: rotate(0deg) translateY(-4px);
}

/* Strip of tape at the top corner. */
.tape {
  position: absolute;
  top: -0.7rem;
  left: 1.9rem;
  width: 4.4rem;
  height: 1.5rem;
  background: var(--tape);
  border-left: 1px dashed rgba(0, 0, 0, 0.08);
  border-right: 1px dashed rgba(0, 0, 0, 0.08);
  transform: rotate(-3.5deg);
}

.card h3 {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 2.15rem;
  line-height: 1.1;
  margin: 0 0 0.1em;
}

.card-link {
  color: var(--ink);
  text-decoration: none;
}
.card-link::after {
  /* Makes the whole card clickable without nesting the link. */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
}
.card-link:hover { color: var(--pencil); }
.card-link:focus-visible {
  outline: 3px solid var(--pencil);
  outline-offset: 6px;
  border-radius: 4px;
}

.kicker {
  font-family: var(--hand);
  font-size: 1.3rem;
  color: var(--pencil);
  margin: 0 0 0.9rem;
}

.card p {
  color: var(--ink-soft);
  font-size: 0.97rem;
  margin: 0 0 1.1rem;
}

.card code {
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 0.86em;
  padding: 0.08em 0.34em;
  border-radius: 3px;
  background: rgba(60, 90, 138, 0.1);
  color: var(--ink);
}

/* Problem / Solution lines on a card. */
.ps { margin: 0 0 0.75rem; }
.ps b {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ink);
  margin-right: 0.35rem;
  background: linear-gradient(transparent 58%, var(--marker) 58%);
}

/* Stack tags — pencil-circled words. */
.stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.card .stack { margin-bottom: 0; }
.stack span {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pencil);
  padding: 0.2rem 0.6rem;
  border: 1px dashed currentColor;
  border-radius: 999px;
  opacity: 0.85;
}

/* ----------------------------------------------------------
   Marginalia
   ---------------------------------------------------------- */

/* A grid item, not a block after the grid — so the arrow always points up at
   a card instead of at the gap an odd card count leaves behind. */
.margin-note {
  font-family: var(--hand);
  font-size: 1.35rem;
  line-height: 1.3;
  color: var(--ink-faint);
  align-self: start;
  padding: 0.35rem 0 0 1.75rem;
  transform: rotate(-1.6deg);
}

/* ----------------------------------------------------------
   Contact
   ---------------------------------------------------------- */

.contact {
  list-style: none;
  margin: 0 0 clamp(3.5rem, 8vw, 5rem);
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2.5rem;
  font-family: var(--hand);
  font-size: clamp(1.4rem, 3.2vw, 1.85rem);
}

.contact a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2.5px solid var(--pencil);
  padding-bottom: 1px;
  transition: color 0.2s ease;
}
.contact a:hover { color: var(--pencil); }
.contact a:focus-visible {
  outline: 3px solid var(--pencil);
  outline-offset: 4px;
}

/* ----------------------------------------------------------
   Colophon
   ---------------------------------------------------------- */

.colophon {
  border-top: 2px solid var(--ink-faint);
  padding-top: 1.1rem;
  filter: url(#rough-4);
}
.colophon p {
  font-family: var(--hand);
  font-size: 1.2rem;
  color: var(--ink-faint);
  margin: 0;
  filter: none;
}
.colophon a {
  color: var(--ink-faint);
  text-decoration: none;
  border-bottom: 1.5px solid currentColor;
  transition: color 0.2s ease;
}
.colophon a:hover { color: var(--pencil); }
.colophon a:focus-visible { outline: 3px solid var(--pencil); outline-offset: 3px; }
.year { float: right; }

/* ==========================================================
   PROJECT PAGES  (public/projects/*.html)
   ========================================================== */

.backlink {
  display: inline-block;
  font-family: var(--hand);
  font-size: 1.35rem;
  color: var(--ink-faint);
  text-decoration: none;
  margin-bottom: 2.25rem;
  transition: color 0.2s ease;
}
.backlink:hover { color: var(--pencil); }
.backlink:focus-visible { outline: 3px solid var(--pencil); outline-offset: 4px; }

.project-head { margin-bottom: clamp(2.5rem, 6vw, 3.75rem); }

.project-head h1 {
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(2.9rem, 8vw, 4.75rem);
  line-height: 1;
  margin: 0 0 0.12em;
}

.project-head .kicker { font-size: 1.5rem; margin-bottom: 1.2rem; }

/* Problem / Solution / anything else — one numbered beat per section. */
.step { margin-bottom: clamp(2.5rem, 6vw, 3.5rem); }

.step h2 {
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 2.7rem);
  line-height: 1.1;
  margin: 0 0 0.6rem;
  display: inline-block;
  background: linear-gradient(transparent 62%, var(--marker) 62%);
}

.step p {
  max-width: 62ch;
  color: var(--ink-soft);
  margin: 0 0 1rem;
}

.step ul {
  max-width: 62ch;
  margin: 0 0 1rem;
  padding-left: 0;
  list-style: none;
}
.step li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--ink-soft);
}
/* Hand-drawn dash instead of a bullet. */
.step li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 0.8rem;
  height: 2px;
  background: var(--pencil);
  opacity: 0.7;
  filter: url(#rough-3);
}

.step code,
.facts code {
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 0.86em;
  padding: 0.08em 0.34em;
  border-radius: 3px;
  background: rgba(60, 90, 138, 0.1);
  color: var(--ink);
}

/* The taped-on facts box. */
.facts {
  position: relative;
  background: var(--paper-shade);
  padding: 1.75rem 1.6rem 1.5rem;
  margin: 0 0 clamp(3rem, 7vw, 4.5rem);
  max-width: 34rem;
  transform: rotate(-0.5deg);
}
.facts::before {
  content: "";
  position: absolute;
  inset: -3px;
  border: 2.5px solid var(--ink);
  border-radius: 12px 9px 14px 10px;
  opacity: 0.85;
  pointer-events: none;
  filter: url(#rough-2);
}

.facts dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1.1rem;
  margin: 0;
  font-size: 0.95rem;
}
.facts dt {
  font-family: var(--hand);
  font-size: 1.2rem;
  color: var(--ink-faint);
  line-height: 1.35;
}
.facts dd { margin: 0; color: var(--ink-soft); }
.facts a { color: var(--pencil); }
.facts a:focus-visible { outline: 3px solid var(--pencil); outline-offset: 3px; }

/* ----------------------------------------------------------
   Small screens
   ---------------------------------------------------------- */

@media (max-width: 34rem) {
  body { font-size: 16px; }
  .card { transform: none !important; }
  .facts { transform: none; }
  .facts dl { grid-template-columns: 1fr; gap: 0.15rem; }
  .facts dd { margin-bottom: 0.7rem; }
  .margin-note { padding-left: 0.5rem; }
  .year { float: none; display: block; }
}

/* ----------------------------------------------------------
   Motion & contrast preferences
   ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .card { transform: none !important; }
}

@media (prefers-contrast: more) {
  :root { --ink-soft: var(--ink); --ink-faint: var(--ink); }
}
