/*
 * The base and layout rules of job-search's stylesheet, cut down to what
 * this page renders: the sign-in form, and a header over the contacts list,
 * whose rules are this page's own. Laptop first and usable on a phone.
 *
 * Every colour below was measured against the surface it actually sits on
 * (2026-09-12, WCAG 2.x relative luminance), not eyeballed. The pairs that
 * matter: light `--ink-2` 7.6:1 on paper and 6.9:1 on ground; light `--muted`
 * 5.3:1 on paper, 4.9:1 on ground and 4.6:1 on raised (the greys one step
 * lighter fail on ground at 4.4:1, so this is the floor); light `--accent`
 * 5.9:1 on paper and white on it 5.9:1; dark `--ink-2` 8.9:1, dark `--muted`
 * 5.6:1 on paper and 5.1:1 on raised; dark `--accent` 7.0:1 on paper and
 * `--ground` on it 7.6:1. The four semantic colours all clear 5.9:1 on paper
 * in both schemes.
 */

:root {
  /* Surfaces, darkest text to lightest ground. */
  --ink: #16181d;
  --ink-2: #4b5563;
  --muted: #646c79;
  --line: #e2e5ea;
  --line-strong: #c9ced6;
  --raised: #eef0f3;
  --paper: #ffffff;
  --ground: #f4f5f7;

  /* One accent for the interactive layer; `--accent-ink` is its label colour. */
  --accent: #1a56e8;
  --accent-ink: #ffffff;

  /*
   * The header mark: the same checkmark as favicon.svg, as a mask-image
   * data URI. A mask reads the shape's alpha, not its colour, so
   * `.top h1::before` paints it with `background-color: var(--accent)` and
   * it needs no dark-mode copy. `ui/favicon.svg` hardcodes `--accent` and
   * `--accent-ink` a second time (a standalone .svg cannot read the page's
   * custom properties), and `ui/apple-touch-icon.png` bakes the light pair
   * in a third time.
   */
  --brand-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3 3 7-7' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  /* A contact card's open/closed mark, painted the same masked way. */
  --disclosure-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 3l5 5-5 5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  /* Semantic: a state, never a decoration. */
  --warm: #8a4b00;
  --danger: #b3261e;
  --success: #0f6b2b;
  --info: #0d5f6c;

  --shadow: 0 0.5rem 2rem rgb(0 0 0 / 18%);
  --shadow-pin: 0 0.25rem 1rem rgb(0 0 0 / 6%);

  /* Spacing: a 4px base. Every margin, padding and gap comes from here. */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-6: 1.5rem;
  --s-8: 2rem;
  --s-12: 3rem;

  /* The header's one-line height, as a fact other rules can read. */
  --top-height: 3.25rem;

  /*
   * Type: five sizes, each with one job. The chrome (buttons, meta, hints)
   * sits at 13px and the content at 15px: a product surface earns its
   * density by setting its controls a step smaller than its text.
   */
  --text-xs: 0.75rem; /* eyebrow labels, counts */
  --text-sm: 0.8125rem; /* chrome: buttons, meta, hints, field labels */
  --text-md: 0.9375rem; /* content: row heads, the reason, fields */
  --text-lg: 1.125rem; /* the one-time code */
  --text-xl: 1.5rem; /* the sign-in statement */

  --r-sm: 0.25rem;
  --r-md: 0.375rem;
  --r-lg: 0.625rem;

  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: 120ms ease-out;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8eaee;
    --ink-2: #b4bac4;
    --muted: #8b93a0;
    --line: #2a2f38;
    --line-strong: #3b414c;
    --raised: #1f232b;
    --paper: #171a20;
    --ground: #0f1115;
    --accent: #7aa2ff;
    --accent-ink: #0f1115;
    --warm: #f0b26b;
    --danger: #ff8a80;
    --success: #5fd97a;
    --info: #5fd0e0;
    --shadow: 0 0.5rem 2rem rgb(0 0 0 / 50%);
    --shadow-pin: 0 0.25rem 1rem rgb(0 0 0 / 40%);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 var(--s-4) var(--s-12);
  background: var(--ground);
  color: var(--ink);
  /*
   * The page never scrolls sideways on a phone. Measured
   * at 360px: one unbreakable token, a PostgREST URL in an error line,
   * spilled 366px out of a 325px paragraph and widened the document to
   * 385px. Set here, once, `anywhere` lets any such run break where it
   * must and touches nothing that already fits.
   */
  overflow-wrap: anywhere;
  font:
    var(--text-md) / 1.5 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
}

main {
  max-width: 60rem;
  margin: 0 auto;
}

h1 {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

p {
  margin: 0;
}

button {
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  min-height: 2rem;
  padding: var(--s-1) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition:
    background-color var(--ease),
    border-color var(--ease),
    color var(--ease);
}

button:hover {
  background: var(--raised);
}

button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

button.primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, var(--ink));
}

button.ghost {
  border-color: transparent;
  background: none;
  color: var(--ink-2);
}

button.ghost:hover {
  background: var(--raised);
  color: var(--ink);
}

/* `appearance: none` on all three: iOS otherwise draws a search field as a
   grey pill with a magnifier and a select as its own control, ignoring the
   border and radius here. The select gets its
   chevron drawn back below. */
input,
select,
textarea {
  appearance: none;
  min-height: 2.25rem;
  padding: var(--s-1) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
  color: inherit;
  font: inherit;
}

select {
  padding-right: var(--s-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-2) center;
  background-size: 1rem;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--accent);
  outline-offset: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Reduced motion: every transition and animation collapses to nothing. */
@media (prefers-reduced-motion: reduce) {
  *,
  ::before,
  ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Header ------------------------------------------------------------ */

/*
 * One row: wordmark, then sign out at the far end. It sticks at every width
 * so sign out stays reachable far down the list.
 */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  height: var(--top-height);
  margin-bottom: var(--s-4);
  background: var(--ground);
  border-bottom: 1px solid var(--line);
}

/* The wordmark and the sign-out never wrap or shrink. */
.top h1 {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
}

/*
 * The mark rides on a pseudo-element, never on `.top h1` itself: a mask clips
 * everything the element paints, so masking the h1 clipped its own text
 * down to the checkmark's shape and the wordmark vanished.
 */
.top h1::before {
  content: "";
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  -webkit-mask: var(--brand-mark) center / contain no-repeat;
  mask: var(--brand-mark) center / contain no-repeat;
  background-color: var(--accent);
}

/* Pinned: once the page has scrolled, a soft shadow says the content is
   passing under the header, not stopping at it. Scroll-driven, no script;
   where the browser lacks it the hairline alone does the job. */
@supports (animation-timeline: scroll()) {
  .top {
    animation: pin linear both;
    animation-timeline: scroll(root);
    animation-range: 0 var(--s-8);
  }
}

@keyframes pin {
  to {
    box-shadow: var(--shadow-pin);
  }
}

.top .sign-out {
  flex: none;
  margin-left: auto;
  white-space: nowrap;
}

/*
 * iOS Safari zooms the page when a field under 16px takes focus and does
 * not zoom back, and a zoomed page scrolls sideways: the horizontal scroll
 * still seen on an iPhone after the layout measured clean in Chrome
 * and WebKit on the real rows (2026-09-12). On a coarse pointer every field
 * is 1rem, so no focus zooms.
 */
@media (pointer: coarse) {
  input,
  select,
  textarea {
    font-size: 1rem;
  }
}

/* --- Status lines ------------------------------------------------------ */

.error {
  margin: 0 0 var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-left: 3px solid currentColor;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: var(--text-sm);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--paper));
}

/* --- Sign-in ----------------------------------------------------------- */

/*
 * No box. A bordered card centred on the page is the default-form look
 * that read as dated; a small wordmark, one statement set
 * large, a field and a button on the plain ground is the whole screen.
 */
.sign-in {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  max-width: 20rem;
  margin: var(--s-12) auto;
}

.sign-in h1 {
  font-size: var(--text-sm);
  color: var(--ink-2);
}

.sign-in .lead {
  margin-bottom: var(--s-2);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

/* Each field's name over its control. */
.sign-in label {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.sign-in label span {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-2);
}

.sign-in input {
  min-height: 2.5rem;
}

/* A one-time code is read digit by digit, so it is set like one. */
.sign-in input[name="code"] {
  font-family: var(--mono);
  font-size: var(--text-lg);
  letter-spacing: 0.12em;
}

.sign-in button {
  min-height: 2.5rem;
  font-size: var(--text-md);
}

.sign-in .error {
  margin: 0;
}

/* --- Contacts ---------------------------------------------------------- */

/*
 * Written here, not taken from job-search: its stylesheet never styled the
 * contacts view. A column of cards, each a native disclosure: closed, it
 * is one scannable line; opened, its eight fields, two to a row on a
 * laptop and one on a phone so every control lines up with the one above
 * it. `<details>`/`<summary>` over a reactive `expanded` ref: a browser
 * gives the open/close toggle keyboard operation and screen-reader
 * semantics for free, and there is no state to keep in sync with 138 rows.
 */

/* The only rule a bare element needs: the pointer says the summary line
   opens something, the rest is the browser's own disclosure triangle. */
/*
 * The collapsed line. `display` is safe here and not on `<details>` itself
 * (see `.panel`): laying out a summary changes nothing about how the
 * browser hides a closed disclosure. Flex is what puts the mark beside the
 * name at all: `.head` is a block, so under the default `list-item` the
 * browser's own triangle took a line of its own above it.
 */
summary {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  cursor: pointer;
  list-style: none;
}

/* Safari draws its marker regardless of the display above. */
summary::-webkit-details-marker {
  display: none;
}

/*
 * The triangle, drawn back: `list-style: none` above took the browser's
 * own away. A mask reads the shape's alpha rather than its colour, the way
 * `--brand-mark` does in the header, so one shape serves both schemes and
 * `--muted` keeps it subordinate to the name beside it.
 */
summary::before {
  content: "";
  flex: none;
  width: 0.6875rem;
  height: 0.6875rem;
  -webkit-mask: var(--disclosure-mark) center / contain no-repeat;
  mask: var(--disclosure-mark) center / contain no-repeat;
  background-color: var(--muted);
  transition: transform var(--ease);
}

.contact[open] > summary::before {
  transform: rotate(90deg);
}

/* The head takes what the mark leaves, and may shrink below its content. */
summary > .head {
  flex: 1;
  min-width: 0;
}

/* The filter bar: the search box takes the room, the state select sits at
   its end, the count trails it. Sticky below the header, its own
   background against the ground so a scrolled card never shows through:
   with 138 rows the search box would otherwise be unreachable without
   scrolling back to the top, and `.top` is already sticky, so this follows
   its lead. */
.contacts > .fields {
  position: sticky;
  top: var(--top-height);
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--s-3);
  padding-block: var(--s-3);
  margin-bottom: var(--s-2);
  background: var(--ground);
}

/* How many of how many: the whole count with nothing filtered, "matched of
   total" once a search or a state narrows it, so a result is never
   mistaken for the whole list. Set with the same monospace as a date, a
   count being a number read at a glance rather than prose. */
.contacts > .fields .count {
  margin-left: auto;
  align-self: center;
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--muted);
  white-space: nowrap;
}

.fields label {
  display: grid;
  gap: var(--s-1);
}

.fields label > span {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-2);
}

.search-box {
  flex: 1 1 16rem;
}

.search-box input {
  width: 100%;
}

.list {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.card {
  padding: var(--s-4);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

/*
 * The grid sits on the panel inside the disclosure, never on `<details>`
 * itself. A `display` other than `block` on `<details>` is where this
 * breaks: the browsers that hide a closed disclosure by hiding a slot in
 * their own shadow tree let the content show through once it is a grid
 * item, and the browsers that hide it with `content-visibility` on
 * `::details-content` wrap every child in one box, so a two-column grid
 * declared up here would collapse into a single cell. Neither shows up in
 * a test: the render tree has no CSS and no layout.
 */
.panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3) var(--s-4);
  margin-top: var(--s-3);
}

/* Everything but the four short fields runs the card's full width. */
.panel > :is(.error, .linkedin-thread, .note, .why, .acts, form) {
  grid-column: 1 / -1;
}

.panel > .error {
  margin: 0;
}

@media (max-width: 40rem) {
  .panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* A name that sits on two domains: the card's edge and the hint say so in
   the warm colour, the one reserved for "look at this". */
.contact.duplicate {
  border-left: 3px solid var(--warm);
}

/*
 * The head, collapsed: the name and how often and how recently on the
 * first line, right-aligned; who they are and where to write on a second
 * line below, in the meta group, so a name is scanned down the page
 * before any of that competes with it. Both wrap rather than truncate.
 */
.head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-1) var(--s-3);
}

.head .name {
  font-weight: 600;
}

/* Everything after the name and the far-right stats: forced onto its own
   line, so it reads as one subordinate group rather than three more
   siblings competing with the name. */
.head .meta {
  display: flex;
  flex-basis: 100%;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-1) var(--s-3);
}

.head .email {
  font-size: var(--text-sm);
  color: var(--ink-2);
}

.head .found-at {
  font-size: var(--text-xs);
  color: var(--muted);
}

.head .company {
  font-size: var(--text-sm);
  color: var(--ink-2);
}

.tag {
  display: inline-block;
  padding: 0 var(--s-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}

.tag.state {
  background: var(--raised);
  color: var(--ink-2);
}

/* A LinkedIn row: the info colour, outlined, so it reads apart from the
   state tag beside it. */
.tag.linkedin {
  border-color: currentColor;
  background: color-mix(in srgb, var(--info) 8%, var(--paper));
  color: var(--info);
}

.linkedin-thread {
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
}

.head .last-contact {
  margin-left: auto;
}

/* Meta, set in the monospace used for a date elsewhere on the page. */
.head :is(.last-contact, .thread-count) {
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.duplicate-hint {
  flex-basis: 100%;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--warm) 10%, var(--paper));
  color: var(--warm);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* A field: its name over its control, the control the field's full width. */
.contact label {
  display: grid;
  gap: var(--s-1);
  align-content: start;
}

.contact label > span {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-2);
}

.contact :is(.note, .alias, .linkedin-url, .connected, .reachable) :is(input, select, textarea) {
  width: 100%;
  min-width: 0;
}

.contact textarea {
  resize: vertical;
}

.contact :is(input, select, textarea):disabled {
  opacity: 0.6;
}

/* The profile field and its open link share a row; the name spans both. */
.contact .linkedin-url {
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--s-2);
}

.contact .linkedin-url > span {
  grid-column: 1 / -1;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--accent);
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--raised);
}

.why {
  padding-left: var(--s-2);
  border-left: 3px solid var(--line-strong);
  font-size: var(--text-sm);
  color: var(--ink-2);
}

.acts,
.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--s-2);
}

/* Drop is the one control that ends a relationship: the danger colour. */
.acts .close {
  color: var(--danger);
}

/* The drop form opens inside the card, set on the raised surface so it
   reads as a step, not another field. */
.panel > form {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: var(--raised);
}

.panel > form .error {
  margin: 0;
}

/* --- Empty list and toast ---------------------------------------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-12) var(--s-4);
  color: var(--muted);
  text-align: center;
}

.empty-mark {
  color: var(--line-strong);
}

/* Bottom centre, over the list, gone on its own. */
.toast {
  position: fixed;
  bottom: var(--s-6);
  left: 50%;
  z-index: 10;
  max-width: calc(100% - 2 * var(--s-4));
  transform: translateX(-50%);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  font-size: var(--text-sm);
  font-weight: 500;
}

.notice {
  border: 1px solid color-mix(in srgb, var(--success) 35%, var(--line));
  background: color-mix(in srgb, var(--success) 8%, var(--paper));
  color: var(--success);
}
