/* Multics — frontend design system.
 *
 * Two pages (index.html, results.html) share these tokens. The look is
 * established by the homepage and must not drift: warm near-black ground,
 * a serif that carries the whole personality, thick-bordered pill shapes
 * for anything you can act on, and no accent colour anywhere. Hierarchy
 * on the results page comes from the weight of the ink, not from boxes.
 */

/* ---------- optional self-hosted display serif ---------------------- *
 * Drop a variable or 400/500 woff2 into search/assets/fonts/ and
 * uncomment. Until then the fallback stack in --font-serif is used and
 * nothing 404s. Keep it same-origin — never link a font CDN here.

@font-face {
  font-family: "Multics Serif";
  src: url("fonts/multics-serif.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}
*/

/* ---------- tokens ---------------------------------------------------- */

:root {
  color-scheme: dark;

  --bg:          #141311;   /* near-black, a hair warm */
  --bg-raised:   #1c1a17;   /* result hover only */
  --text:        #e9e3d6;   /* parchment — wordmark, titles, matches */
  --text-dim:    #a29b8d;   /* domain, snippet body */
  --text-faint:  #6f6a5f;   /* dates, footer, placeholder */
  --hair:        rgba(233, 227, 214, 0.11);
  --hair-strong: rgba(233, 227, 214, 0.30);
  --border-pill: #d9d3c5;   /* thick borders: interactive pills only */
  --focus:       #e9e3d6;

  /* One serif carries the whole personality. It is served from our own
   * origin, never a font CDN: a search engine that never talks to a
   * server for a query should not leak one for a typeface either.
   * "Multics Serif" is the optional self-hosted face (see the @font-face
   * block below and search/README.md); the rest is a quality fallback
   * so an install with no webfont still looks deliberate. */
  --font-serif: "Multics Serif", "Source Serif 4", "Noto Serif",
                "Iowan Old Style", "Palatino Linotype", Palatino, Charter,
                Georgia, "Times New Roman", serif;
  --font-sans:  system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
                Roboto, "Helvetica Neue", Arial, sans-serif;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.5rem;
  --space-8: 4rem;
  --space-9: 6rem;

  --col: 40rem;         /* reading column, keeps lines under ~80ch */
  --tap: 2.75rem;       /* 44px minimum touch target */
  --pill-radius: 999px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg:          #f4efe4;
  --bg-raised:   #eae2d2;
  --text:        #1c1915;
  --text-dim:    #5c554a;
  --text-faint:  #8a8272;
  --hair:        rgba(28, 25, 21, 0.12);
  --hair-strong: rgba(28, 25, 21, 0.30);
  --border-pill: #2a2620;
  --focus:       #1c1915;
}

/* ---------- reset / base ------------------------------------------------ */

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

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

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.0625rem;              /* 17px — serif body comfort */
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- corner navigation (shared) -------------------------------- */

.corner-nav {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  display: flex;
  gap: var(--space-3);
  z-index: 20;
}

.corner-nav__btn {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 1px solid var(--hair-strong);
  border-radius: var(--pill-radius);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease),
              background-color 0.15s var(--ease);
}

.corner-nav__btn:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.corner-nav__btn svg {
  width: 1.125rem;
  height: 1.125rem;
  display: block;
}

/* theme icon: show the one for the theme you'd switch TO — driven by the
 * root attribute so it's correct before any script runs */
.corner-nav__btn [data-icon="light"] { display: none; }
:root[data-theme="light"] .corner-nav__btn [data-icon="dark"]  { display: none; }
:root[data-theme="light"] .corner-nav__btn [data-icon="light"] { display: block; }

/* ---------- the search field (shared shape) ------------------------- */

.field {
  display: flex;
  align-items: center;
  width: 100%;
  border: 2px solid var(--border-pill);
  border-radius: var(--pill-radius);
  background: transparent;
  transition: border-color 0.15s var(--ease);
}

.field:focus-within {
  border-color: var(--text);
  animation: field-focus-pop 0.22s var(--ease) both;
}

@keyframes field-focus-pop {
  0%   { box-shadow: 0 0 0 0    var(--border-pill); }
  55%  { box-shadow: 0 0 0 9px  var(--border-pill); }
  100% { box-shadow: 0 0 0 5px  var(--border-pill); }
}

.field__input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-serif);
  line-height: 1.2;
}

.field__input::placeholder { color: var(--text-faint); opacity: 1; }
.field__input:focus { outline: none; }

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

/* ---------- homepage ------------------------------------------------- */

.home {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(4rem, 21vh, 12rem) var(--space-5) var(--space-8);
}

.home__wordmark {
  margin: 0;
  font-weight: 500;
  font-size: clamp(3rem, 8vw, 4rem);
  letter-spacing: 0.01em;
  line-height: 1;
}

.home__field {
  margin-top: var(--space-7);
  max-width: 42rem;
  height: 4.5rem;
  padding: 0 var(--space-6);
}

.home__field .field__input { font-size: 1.375rem; }

.home__note {
  margin-top: 16vh;
  max-width: 34rem;
  text-align: center;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-faint);
}

.home__note a { text-underline-offset: 2px; }

.home__legal {
  margin-top: var(--space-4);
  font-size: 0.875rem;
}

.home__legal a { text-underline-offset: 2px; }

/* ---------- results: header --------------------------------------- */

/* Two rows, always: [wordmark ........ icons] then [ search field ].
 * The header owns its controls here (the floating corner-nav is a
 * homepage device). Everything aligns to the same column as the result
 * list below it, and the whole thing stays compact enough to sit
 * sticky without eating a phone screen. */

.masthead {
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease);
}

.masthead[data-stuck="true"] { border-bottom-color: var(--hair); }

.masthead__inner {
  width: min(100% - 2 * var(--space-5), var(--col));
  margin-inline: auto;
  padding-block: var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.masthead__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.masthead .corner-nav {
  position: static;
  gap: var(--space-3);
}

.masthead__home {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.5rem;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.masthead__field {
  height: 3.25rem;
  padding: 0 var(--space-5);
}

.masthead__field .field__input { font-size: 1.0625rem; }

/* ---------- results: body ---------------------------------------- */

.results {
  width: min(100% - 2 * var(--space-5), var(--col));
  margin-inline: auto;
  padding-block: var(--space-6) var(--space-9);
}

.results__count {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-faint);
  margin: 0 0 var(--space-6);
  min-height: 1.2em;
}

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

.result {
  padding-block: var(--space-2);
}

.result + .result { margin-top: var(--space-7); }

/* whole block is the target; the tint answers the pointer */
.result__link {
  display: block;
  text-decoration: none;
  margin-inline: calc(-1 * var(--space-4));
  padding: var(--space-3) var(--space-4);
  border-radius: 0.5rem;
  transition: background-color 0.12s var(--ease);
}

.result__link:hover { background: var(--bg-raised); }
.result__link:hover .result__title { text-decoration: underline; }
.result__link:focus-visible { outline-offset: -2px; }

.result__title {
  display: block;
  font-size: 1.3125rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text);
  text-underline-offset: 3px;
}

.result__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-3);
  margin-top: var(--space-2);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.result__domain { color: var(--text-dim); }
.result__date { color: var(--text-faint); }

.result__snippet {
  display: block;
  margin-top: var(--space-3);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-dim);
}

/* search-term matches: no colour, just brought up to full strength and a
 * touch heavier so the eye finds the hit inside the dimmed line */
.result__snippet b {
  font-weight: 600;
  color: var(--text);
}

/* ---------- results: states & controls ------------------------- */

.state {
  padding-block: var(--space-6);
  max-width: 32rem;
}

.state__title {
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0 0 var(--space-3);
}

.state__body {
  margin: 0;
  color: var(--text-dim);
  font-size: 1rem;
}

.state__body a { text-underline-offset: 2px; }

.state__body code {
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", "Menlo", monospace;
  font-size: 0.875em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.progress {
  margin-top: var(--space-4);
  height: 2px;
  width: 100%;
  background: var(--hair);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  width: 0;
  background: var(--text-dim);
  transition: width 0.2s linear;
}

.progress[data-indeterminate="true"] .progress__bar {
  width: 33%;
  animation: sweep 1.1s var(--ease) infinite;
}

@keyframes sweep {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(330%); }
}

.more {
  display: block;
  margin: var(--space-8) auto 0;
  min-height: var(--tap);
  padding: 0 var(--space-6);
  border: 2px solid var(--border-pill);
  border-radius: var(--pill-radius);
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.more:hover { border-color: var(--text); }

.results__foot {
  margin-top: var(--space-9);
  padding-top: var(--space-5);
  border-top: 1px solid var(--hair);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  line-height: 1.7;
  color: var(--text-faint);
}

.results__foot a { text-underline-offset: 2px; }
.results__foot p { margin: 0; }

/* one render-time fade, nothing per-item */
.fade-in { animation: fade 0.18s var(--ease) both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- mobile ------------------------------------------------- */

@media (max-width: 34rem) {
  .corner-nav {
    top: var(--space-3);
    right: var(--space-3);
    gap: var(--space-2);
  }

  .home { padding: 14vh var(--space-4) var(--space-7); }
  .home__field {
    height: 3.75rem;
    padding: 0 var(--space-5);
  }
  .home__field .field__input { font-size: 1.125rem; }
  .home__note { margin-top: 12vh; }

  /* keep the sticky header tight: wordmark + icons row, then the field */
  .masthead__inner {
    width: calc(100% - 2 * var(--space-4));
    padding-block: var(--space-3);
    gap: var(--space-2);
  }
  .masthead__home { font-size: 1.375rem; }
  .masthead .corner-nav { gap: var(--space-2); }
  .masthead__field { height: 3rem; }

  .results {
    width: calc(100% - 2 * var(--space-4));
    padding-block: var(--space-5) var(--space-8);
  }
  .result + .result { margin-top: var(--space-6); }
  .result__link {
    margin-inline: calc(-1 * var(--space-3));
    padding-inline: var(--space-3);
  }
  .result__title { font-size: 1.1875rem; }
  .more { width: 100%; }
}

/* ---------- search result flag button --------------------------------- */

.result { position: relative; }

.result__flag {
  position: absolute;
  top: calc(var(--space-2) + var(--space-3));
  right: 0;
  z-index: 1;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 0.25rem;
  opacity: 0;
  transition: opacity 0.12s var(--ease), color 0.12s var(--ease);
}

.result:hover .result__flag,
.result__flag:focus-visible { opacity: 1; }

.result__flag:hover { color: var(--text-dim); }

/* ---------- modals (submit + report) ---------------------------------- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  place-items: center;
  padding: var(--space-5);
  z-index: 100;
}

.modal-overlay[aria-hidden="false"] {
  display: grid;
  animation: overlay-in 0.15s var(--ease) both;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: 28rem;
  background: var(--bg);
  border: 2px solid var(--border-pill);
  border-radius: 1.25rem;
  padding: var(--space-6);
}

.modal-overlay[aria-hidden="false"] .modal {
  animation: modal-in 0.15s var(--ease) both;
}

@keyframes modal-in {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.modal__title {
  font-family: var(--font-serif);
  font-size: 1.1875rem;
  font-weight: 500;
  margin: 0;
  line-height: 1.3;
}

.modal__url {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-dim);
  margin: 0 0 var(--space-4);
  overflow-wrap: anywhere;
  word-break: break-all;
}

.modal__field { margin-bottom: var(--space-4); }

.modal__label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text-dim);
  margin-bottom: var(--space-2);
}

.modal__input {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: 1.5px solid var(--hair-strong);
  border-radius: 0.5rem;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.4;
  transition: border-color 0.12s var(--ease);
}

.modal__input:focus {
  outline: none;
  border-color: var(--border-pill);
}

textarea.modal__input {
  resize: vertical;
  min-height: 5rem;
}

select.modal__input {
  font-family: var(--font-sans);
  cursor: pointer;
}

.modal__status {
  min-height: 1.4em;
  margin: var(--space-4) 0 0;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-dim);
}

.modal__status--ok  { color: var(--text); }
.modal__status--err {
  color: var(--text);
  border-left: 2px solid var(--border-pill);
  padding-left: var(--space-3);
}

.modal__btn {
  display: block;
  width: 100%;
  margin-top: var(--space-5);
  min-height: var(--tap);
  padding: 0 var(--space-6);
  border: 2px solid var(--border-pill);
  border-radius: var(--pill-radius);
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), opacity 0.15s var(--ease);
}

.modal__btn:hover                 { border-color: var(--text); }
.modal__btn:disabled               { opacity: 0.4; cursor: default; }
.modal__btn:disabled:hover         { border-color: var(--border-pill); }

@media (max-width: 34rem) {
  .result__flag { right: calc(-1 * var(--space-1)); }
  .modal { padding: var(--space-5); border-radius: 1rem; }
}
