/* =========================================================================
   Personal Portfolio — "Monochrome"
   Achromatic: near-black ground, near-white type, no hue anywhere.
   See DESIGN.md for the system and its named rules.
   ========================================================================= */

:root {
  /* Neutrals — chroma 0, ordered by value (see The Value Ladder Rule) */
  --ink: oklch(14.5% 0 0); /* background */
  --graphite: oklch(19% 0 0); /* raised surfaces */
  --rule: oklch(28% 0 0); /* 1px hairlines */
  --faint: oklch(48% 0 0); /* decorative glyphs, not text */
  --ash: oklch(68% 0 0); /* secondary text */
  --paper: oklch(96% 0 0); /* primary text */

  /* Type */
  --serif: "EB Garamond", Garamond, "Hoefler Text", Georgia, serif;

  /* Spacing — 4pt base */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-24: 6rem;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 160ms;
}

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

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

body {
  position: relative; /* anchors the account corner to the page bottom */
  min-height: 100vh;
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 1.1875rem; /* 19px: Garamond's small x-height needs the extra size */
  line-height: 1.55;
  font-variant-numeric: oldstyle-nums;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--paper);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
}

/* --- Layout: single narrow column, generous, left-aligned ------------------ */

.page {
  width: 100%;
  max-width: 52rem; /* ~832px */
  margin-inline: auto;
  padding: clamp(var(--sp-8), 6vw, var(--sp-12)) clamp(var(--sp-4), 4vw, var(--sp-8)) var(--sp-12);
}

/* Entrance: one settle of the whole column, no per-section choreography */
@media (prefers-reduced-motion: no-preference) {
  .page {
    animation: rise 0.7s var(--ease-out) both;
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --- Intro ---------------------------------------------------------------- */

.intro {
  margin-bottom: var(--sp-16);
}

.name {
  margin: 0;
  font-size: clamp(2.75rem, 8vw, 4.5rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.tagline {
  max-width: 40ch;
  margin: var(--sp-4) 0 0;
  font-size: 1.375rem;
  color: var(--paper);
  text-wrap: pretty;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-3);
  margin: var(--sp-6) 0 0;
  font-size: 1.0625rem;
  font-style: italic;
  color: var(--ash);
}

.meta-line .dot {
  color: var(--faint);
}


/* --- Section index -------------------------------------------------------- */

.index {
  margin-bottom: var(--sp-12);
}

.kicker {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin: 0 0 var(--sp-3);
  font-size: 1.0625rem;
  font-weight: 500;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.14em;
  color: var(--ash);
}

.kicker .num {
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--faint);
}

/* --- Rows: typographic, not cards ----------------------------------------- */

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rows li + li {
  border-top: 1px solid var(--rule);
}

.row {
  display: block;
  padding: var(--sp-4) 0;
  transition: transform var(--dur) var(--ease-out);
}

.row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
}

.row-title {
  margin: 0;
  font-size: 1.625rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--paper);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: transparent;
  transition: text-decoration-color var(--dur) var(--ease-out);
}

/* "go to detail" marker: hidden until the row wakes up */
.row-title::after {
  content: " \2192"; /* → */
  font-weight: 400;
  color: var(--paper);
  opacity: 0;
  transform: translate(-2px, 2px);
  display: inline-block;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}

.row-year {
  flex: none;
  font-size: 1.0625rem;
  font-style: italic;
  color: var(--ash);
  transition: color var(--dur) var(--ease-out);
}

.row-context {
  display: block;
  max-width: 60ch;
  margin-top: var(--sp-1);
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--ash);
}

/* Hover / focus: the title underlines and the metadata brightens */
a.row:hover .row-title,
a.row:focus-visible .row-title {
  text-decoration-color: var(--paper);
}
a.row:hover .row-year,
a.row:focus-visible .row-year {
  color: var(--paper);
}
a.row:hover .row-title::after,
a.row:focus-visible .row-title::after {
  opacity: 1;
  transform: none;
}
a.row:hover {
  transform: translateX(3px);
}

a.row:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 6px;
  border-radius: 3px;
}

/* --- About: label / value pairs ---------------------------------------- */

.about-list {
  margin: 0;
}

.about-item {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: var(--sp-4);
  align-items: baseline;
  padding: var(--sp-2) 0;
}
.about-item + .about-item {
  border-top: 1px solid var(--rule);
}

.about-label {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.1em;
  color: var(--ash);
}

.about-item dd {
  margin: 0;
}

/* About values are the page's always-underlined links */
a.about-value {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
  text-decoration-color: var(--faint);
  transition: text-decoration-color var(--dur) var(--ease-out);
}
a.about-value:hover {
  text-decoration-color: var(--paper);
}
a.about-value:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
  border-radius: 2px;
}

/* --- Account corner: sign in / edit / sign out --------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
  border-radius: 2px;
}

.account {
  position: absolute;
  bottom: var(--sp-4);
  right: clamp(var(--sp-4), 4vw, var(--sp-8));
  z-index: 2;
  display: flex;
  gap: var(--sp-4);
  align-items: baseline;
}

.account-toggle,
.account-edit {
  font-size: 1rem;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.1em;
  color: var(--ash);
  transition: color var(--dur) var(--ease-out);
}
.account-toggle:hover,
.account-edit:hover {
  color: var(--paper);
}

/* Signed out, the sign-in button is camouflaged: Ink on Ink, and only a
   one-step shift to Graphite on hover gives it away. Keyboard focus still
   shows the normal ring so it stays reachable. */
.account:not(.is-signed-in) .account-toggle {
  padding: var(--sp-1) var(--sp-2);
  border-radius: 2px;
  color: var(--ink);
  background: var(--ink);
  transition: background-color var(--dur) var(--ease-out);
}
.account:not(.is-signed-in) .account-toggle:hover,
.account:not(.is-signed-in) .account-toggle[aria-expanded="true"] {
  color: var(--ink);
  background: var(--graphite);
}

/* Clear the fixed save bar while editing */
body.is-editing .account {
  bottom: calc(var(--sp-16) + var(--sp-4));
}

/* Drops down under the corner link; a panel, not a modal */
/* Opens upward from the bottom corner */
.sign-in {
  position: absolute;
  bottom: calc(100% + var(--sp-2));
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-2) var(--sp-3);
  width: 17rem;
  padding: var(--sp-4);
  background: var(--graphite);
  border: 1px solid var(--rule);
}
.sign-in[hidden] {
  display: none;
}

.sign-in label {
  grid-column: 1 / -1;
  font-size: 1rem;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.1em;
  color: var(--ash);
}

.sign-in input {
  min-width: 0;
  padding: var(--sp-1) 0;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--faint);
  border-radius: 0;
}
.sign-in input:focus-visible {
  outline: none;
  border-bottom-color: var(--paper);
}

.sign-in button {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.1em;
}

.sign-in-error {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 1rem;
  font-style: italic;
  color: var(--paper);
}
.sign-in-error:empty {
  display: none;
}

/* --- Edit mode ------------------------------------------------------------ */

/* Editable fields: a dotted underline marks what can change */
.editable {
  text-decoration: underline dotted var(--faint);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  cursor: text;
}
.editable:hover {
  text-decoration-color: var(--ash);
}
.editable:focus {
  outline: none;
  text-decoration-style: solid;
  text-decoration-color: var(--paper);
}
.editable:empty::before {
  content: attr(data-placeholder);
  font-style: italic;
  color: var(--faint);
}
/* An empty field still needs width to be clickable */
.editable:empty {
  display: inline-block;
  min-width: 6ch;
}

.row-tools {
  display: flex;
  gap: var(--sp-3);
  align-items: baseline;
  margin-top: var(--sp-2);
  font-size: 1rem;
}

.tool-label {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.1em;
  color: var(--faint);
}

.row-href {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ash);
}

.tool {
  font-size: 1rem;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.1em;
  color: var(--ash);
  transition: color var(--dur) var(--ease-out);
}
.tool:hover {
  color: var(--paper);
}

.tool-add {
  margin-top: var(--sp-2);
}

/* The one inverted element: the save bar */
.edit-bar {
  position: fixed;
  inset: auto 0 0;
  z-index: 3;
  display: flex;
  gap: var(--sp-6);
  align-items: baseline;
  padding: var(--sp-3) clamp(var(--sp-4), 4vw, var(--sp-8));
  background: var(--paper);
  color: var(--ink);
}
.edit-bar[hidden] {
  display: none;
}

.edit-status {
  flex: 1;
  margin: 0;
  font-style: italic;
}

.edit-bar button {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.1em;
}
.edit-bar .edit-save {
  font-weight: 600;
}
.edit-bar button:focus-visible {
  outline-color: var(--ink);
}
.edit-bar button:disabled {
  cursor: progress;
  opacity: 0.5;
}

/* Keep the last fields clear of the fixed bar */
body.is-editing {
  padding-bottom: var(--sp-16);
}

/* --- Reduced motion: strip transforms, keep instant feedback -------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation: none !important;
  }
  a.row:hover {
    transform: none;
  }
}

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

@media (max-width: 34rem) {
  body {
    font-size: 1.125rem;
  }
  .row-head {
    flex-direction: column;
    gap: var(--sp-1);
  }
  .row-year {
    order: -1; /* year sits above the title, like a dateline */
    color: var(--ash);
  }
  .index {
    margin-bottom: var(--sp-8);
  }
  .about-item {
    grid-template-columns: 5.5rem 1fr;
  }
  .edit-bar {
    gap: var(--sp-4);
  }
}
