:root {
  --navy: #1c2b4b;        /* main text */
  --navy-soft: #56647f;   /* secondary text */
  --ink: #000000;         /* header text + box borders */
  --white: #ffffff;       /* box background */
  --bg: #f4f6fa;
  --mist: #f1f3f7;
  --signal: #c4343c;
  --rule: #d6dbe4;
  --stripe: rgba(28, 43, 75, 0.16);

  --serif: "Young Serif", Georgia, serif;
  --sans: "Public Sans", system-ui, -apple-system, sans-serif;
  --wide: 1040px;
}

:root[data-theme="dark"] {
  --navy: #e4e9f2;
  --navy-soft: #98a4ba;
  --ink: #e4e9f2;
  --white: #15203a;
  --bg: #0c1424;
  --mist: #1d2a46;
  --rule: #2b3a58;
  --stripe: rgba(170, 190, 225, 0.09);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--navy);
  text-transform: lowercase;
  /* Breton stripes */
  background-color: var(--bg);
  background-image: repeating-linear-gradient(to bottom, var(--stripe) 0 3px, transparent 3px 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  padding: 28px 32px 0;
}

a { color: inherit; }
button { font: inherit; color: inherit; text-transform: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
.muted { color: var(--navy-soft); }
.small { font-size: 13.5px; }
.label { font-size: 13px; color: var(--navy-soft); margin-bottom: 6px; }

/* ---------- header: plain text on the stripes ---------- */
.top {
  flex: none;
  width: 100%;
  max-width: var(--wide);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  color: var(--ink);
}
.name {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1;
  text-decoration: none;
}
.tabs { display: flex; gap: 26px; align-items: baseline; }
.tabs a, .theme {
  font-size: 14px;
  text-decoration: none;
  color: var(--ink);
  padding: 0 0 3px;
  border-bottom: 1.5px solid transparent;
}
.tabs a:hover { border-bottom-color: var(--rule); }
.tabs a[aria-current="page"] { border-bottom-color: var(--ink); }
.theme {
  background: none;
  border-top: 0; border-left: 0; border-right: 0;
  cursor: pointer;
  opacity: 0.6;
}
.theme:hover { opacity: 1; }

/* ---------- layout ---------- */
main {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: var(--wide);
  overflow: hidden;
  padding: 24px 0 12px;
  display: flex;
  flex-direction: column;
}
.subtabs { flex: none; display: flex; gap: 20px; margin-bottom: 14px; }
.subtabs[hidden] { display: none; }
.subtabs a {
  font-size: 14px;
  text-decoration: none;
  color: var(--ink);
  opacity: 0.6;
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
}
.subtabs a:hover { opacity: 1; }
.subtabs a[aria-current="page"] { opacity: 1; border-bottom-color: var(--ink); }
.view { flex: 1; min-height: 0; display: grid; gap: 20px; align-content: start; animation: rise 0.28s ease-out; }
.view[hidden] { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } }

.foot {
  flex: none;
  padding: 0 0 12px;
  font-size: 12px;
  color: var(--navy-soft);
}
.foot span { background: var(--bg); padding: 2px 8px; }

/* ---------- cards ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--ink);
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 22px 22px;
}
.title {
  margin: 0 0 14px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--navy-soft);
}
.body { margin: 0; padding: 0; }
.big { font-family: var(--serif); font-size: 20px; line-height: 1.3; margin-bottom: 8px !important; }

.rows div { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border-top: 1px solid var(--rule); }
.rows div:first-child { border-top: 0; }
.rows dt { color: var(--navy-soft); flex: none; }
.rows dd { margin: 0; text-align: right; }

/* ---------- home ---------- */
.view-home {
  grid-template-columns: 250px minmax(0, 1fr);
  grid-template-areas:
    "wx    hello"
    "links now";
}
.c-wx { grid-area: wx; }
.c-hello { grid-area: hello; }
.c-links { grid-area: links; }
.c-now { grid-area: now; }

.hello { font-family: var(--serif); font-size: 32px; line-height: 1.15; margin-bottom: 14px !important; }
.c-hello p { max-width: 64ch; }

.wx-temp { font-family: var(--serif); font-size: 46px; line-height: 1; }
.wx-desc { color: var(--navy-soft); margin: 6px 0 10px !important; }
.c-wx .rows div:first-child { border-top: 1px solid var(--rule); }

.links { list-style: none; display: grid; gap: 10px; align-content: start; }
.links a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.links a:hover { border-color: var(--navy); }

.now { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 28px; }
.now li { display: grid; gap: 1px; align-content: start; }
.now b { font-family: var(--serif); font-weight: 400; font-size: 18px; line-height: 1.25; }
.now .role { font-size: 12.5px; font-weight: 500; }
.now li > span:last-child { color: var(--navy-soft); font-size: 14px; line-height: 1.45; margin-top: 3px; }

/* ---------- about ---------- */
.view-about {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  grid-template-areas:
    "me      school"
    "classes tools";
}
.c-me { grid-area: me; }
.c-school { grid-area: school; }
.c-classes { grid-area: classes; }
.c-tools { grid-area: tools; }
.c-me p { max-width: 62ch; }

/* ---------- experience ---------- */
.roles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--rule); margin-bottom: 22px; }
.roles button {
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 0 12px 12px 0;
  cursor: pointer;
  display: grid;
  gap: 1px;
  color: var(--navy-soft);
}
.roles button:hover { color: var(--navy); }
.roles button[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--navy); }
.roles .r-co { font-family: var(--serif); font-size: 19px; line-height: 1.25; }
.roles .r-when { font-size: 12.5px; }

.role { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 36px; }
.role h2 { font-family: var(--serif); font-weight: 400; font-size: 24px; line-height: 1.2; margin: 0 0 8px; }
.role .role-meta { color: var(--navy-soft); font-size: 13.5px; }
.role ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; align-content: start; }
.role li { position: relative; padding-left: 20px; max-width: 68ch; }
.role li::before { content: "–"; position: absolute; left: 0; color: var(--navy-soft); }

/* ---------- research & projects ---------- */
.view-work { grid-template-rows: minmax(0, auto); }
.c-work { max-height: 100%; }
.c-work .body { display: flex; flex-direction: column; min-height: 0; }
.work-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--rule); }

.switch { display: inline-flex; gap: 18px; }
.switch button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 1px 0;
  cursor: pointer;
  color: var(--navy-soft);
  font-weight: 500;
}
.switch button:hover { color: var(--navy); }
.switch button[aria-selected="true"], .switch button[aria-pressed="true"] { color: var(--navy); border-bottom-color: var(--navy); }

.research-blurb { font-size: 16px; line-height: 1.65; }
.research-blurb ul { margin: 0 0 16px; padding: 0; list-style: none; display: grid; gap: 12px; }
.research-blurb b { font-family: var(--serif); font-weight: 400; }
.entries[hidden] { display: none; }
.more { margin: 22px 0 0 !important; color: var(--navy-soft); }
.more a { color: var(--navy); text-decoration: none; border-bottom: 1px solid var(--rule); }
.more a:hover { border-color: var(--navy); }

.entries {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 40px;
  align-content: start; overflow-y: auto; min-height: 0;
}
.entries li { display: grid; align-content: start; }
.e-name { font-family: var(--serif); font-size: 17px; line-height: 1.3; }
.e-name a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.e-name a:hover { border-color: var(--navy); }
.e-where { font-size: 13px; color: var(--navy-soft); }
.e-desc { margin: 4px 0 0 !important; }

/* ---------- books & movies ---------- */
.view-shelf { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
.shelf { list-style: none; display: grid; gap: 14px; align-content: start; }
.shelf li { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-content: start; }
.shelf li .muted { grid-column: 1 / -1; font-size: 13.5px; }
.shelf-title { font-family: var(--serif); font-size: 17px; line-height: 1.3; }
.card > .body > .shelf-title { font-size: 22px; margin-bottom: 4px !important; }
.stars { letter-spacing: 0.08em; white-space: nowrap; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 36px; }

/* ---------- puzzle ---------- */
.view-puzzle { grid-template-columns: minmax(0, 1fr) 290px; grid-template-rows: minmax(0, 1fr); }
.c-board { min-height: 0; }
.board-wrap { flex: 1; min-height: 0; display: grid; place-items: center; }
.board { position: relative; background-color: var(--mist); touch-action: none; user-select: none; }
.board:not(.peek) { background-image: none !important; }
.board.peek .piece { opacity: 0; }
.piece {
  position: absolute;
  background-repeat: no-repeat;
  cursor: grab;
  outline: 1px solid rgba(255, 255, 255, 0.6);
  outline-offset: -1px;
  transition: left 0.22s ease, top 0.22s ease, opacity 0.2s;
}
.piece.dragging { transition: none; z-index: 5; cursor: grabbing; box-shadow: 0 8px 18px rgba(28, 43, 75, 0.35); }
.piece.picked { outline: 3px solid var(--signal); outline-offset: -3px; z-index: 2; }
.piece.home { outline-color: transparent; }
.board.solved .piece { outline: 0; cursor: default; }

.c-controls { align-self: start; }
.controls { display: flex; flex-direction: column; gap: 16px; }
.photo-list { display: grid; gap: 4px; }
.photo-list button {
  text-align: left; background: none; border: 0; border-left: 3px solid transparent;
  padding: 4px 8px; cursor: pointer; display: flex; align-items: center; gap: 10px;
}
.photo-list button:hover { background: var(--mist); }
.photo-list button[aria-pressed="true"] { border-left-color: var(--navy); background: var(--mist); }
.photo-list img { width: 32px; height: 32px; object-fit: cover; flex: none; }
.photo-list .p-name { font-size: 14px; line-height: 1.25; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; border-top: 1px solid var(--rule); padding-top: 10px; }
.stats dt { font-size: 12px; color: var(--navy-soft); }
.stats dd { margin: 0; font-family: var(--serif); font-size: 22px; line-height: 1.2; }

.btns { display: flex; gap: 10px; }
.btn { flex: 1; padding: 8px 12px; background: var(--navy); color: var(--white); border: 1.5px solid var(--navy); cursor: pointer; font-weight: 500; }
.btn:hover { opacity: 0.88; }
.btn-line { background: var(--white); color: var(--navy); }
.btn-line:hover, .btn-line[aria-pressed="true"] { background: var(--mist); }
.win { margin: 0 !important; font-weight: 500; }

/* ---------- short laptop screens ---------- */
@media (max-height: 820px) and (min-height: 641px) {
  body { padding-top: 18px; }
  main { padding-top: 18px; }
  .card { padding: 16px 18px 18px; }
  .hello { font-size: 28px; }
  .view { gap: 16px; }
}

/* ---------- phones and short windows: scrolling allowed as a fallback ---------- */
@media (max-width: 900px), (max-height: 640px) {
  body { overflow: auto; height: auto; min-height: 100%; }
  main { overflow: visible; }
  .view { height: auto; }
  .c-work { max-height: none; }
  .entries { overflow: visible; }
}
@media (max-width: 900px) {
  body { padding: 16px 16px 0; }
  .top { flex-direction: column; align-items: flex-start; gap: 12px; }
  .tabs { gap: 16px; flex-wrap: wrap; }
  .tabs a { font-size: 13px; padding-bottom: 10px; }
  .view-home, .view-about, .view-puzzle, .view-shelf, .role { grid-template-columns: minmax(0, 1fr); grid-template-areas: none; }
  .view-home > *, .view-about > * { grid-area: auto; }
  .c-hello { order: -1; }
  .now, .entries, .two-col { grid-template-columns: minmax(0, 1fr); }
  .roles { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); row-gap: 10px; }
  .role { gap: 16px; }
  .view-puzzle { grid-template-rows: auto; }
  .board-wrap { aspect-ratio: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
  .piece { transition: none; }
}
