/* FLYNN Search — homepage design system */

:root {
  --font-ui: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mark: "Syne", "Inter", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t: 420ms;
  --theme-t: 340ms;
  --search-w: min(612px, calc(100vw - 48px));
  --pad-x: 24px;
  --blur: 7px;
  --sig: 245, 244, 240;
}

html[data-theme="dark"] {
  --bg: #0c0c0b;
  --bg-lift: #141413;
  --ink: #f3f2ee;
  --ink-soft: #c6c4bc;
  --muted: #8a8983;
  --mute-2: #6a6964;
  --line: #262624;
  --shell: #161615;
  --btn: #1c1c1a;
  --btn-hover: #242422;
  --focus-ring: rgba(243, 242, 238, 0.34);
  --panel-veil: rgba(12, 12, 11, 0.72);
  --sig: 243, 242, 238;
}

html[data-theme="light"] {
  --bg: #f5f4f0;
  --bg-lift: #eceae4;
  --ink: #121211;
  --ink-soft: #3a3a36;
  --muted: #7a7973;
  --mute-2: #9b9a94;
  --line: #e4e2db;
  --shell: #ecebe6;
  --btn: #e6e4de;
  --btn-hover: #dddbd4;
  --focus-ring: rgba(18, 18, 17, 0.28);
  --panel-veil: rgba(245, 244, 240, 0.72);
  --sig: 18, 18, 17;
}

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

html,
body {
  height: 100%;
}

html {
  background: var(--bg);
  color-scheme: dark;
  transition: background-color var(--theme-t) var(--ease);
}

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font-ui);
  font-optical-sizing: auto;
  font-weight: 400;
  letter-spacing: -0.011em;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition:
    background-color var(--theme-t) var(--ease),
    color var(--theme-t) var(--ease);
}

.page {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: minmax(72px, 1fr) auto minmax(96px, 1fr);
  align-items: center;
  padding: 0 var(--pad-x) 0;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: 12px;
  z-index: 30;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  font-size: 13px;
  border-radius: 4px;
  clip-path: inset(100%);
}

.skip-link:focus {
  clip-path: none;
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

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

/* Theme toggle */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 20;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color var(--theme-t) var(--ease), background-color 220ms var(--ease);
}

.theme-toggle:hover {
  color: var(--ink);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

.theme-icon {
  grid-area: 1 / 1;
  display: flex;
  transition: opacity 280ms var(--ease), transform 280ms var(--ease);
}

.theme-icon-sun {
  opacity: 0;
  transform: scale(0.72);
}

.theme-icon-moon {
  opacity: 1;
  transform: scale(1);
}

html[data-theme="light"] .theme-icon-sun {
  opacity: 1;
  transform: scale(1);
}

html[data-theme="light"] .theme-icon-moon {
  opacity: 0;
  transform: scale(0.72);
}

/* Quiet layer — this is what softens on focus */
.quiet {
  grid-row: 1;
  align-self: end;
  width: 100%;
  transition:
    filter var(--t) var(--ease),
    opacity var(--t) var(--ease);
  will-change: filter, opacity;
}

.masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-bottom: 26px;
  padding-top: 28px;
}

.ambient {
  width: 220px;
  height: 40px;
  margin-bottom: 22px;
  opacity: 0.5;
  transition: opacity var(--t) var(--ease);
}

.ambient canvas {
  display: block;
  width: 220px;
  height: 40px;
}

.wordmark {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.wordmark-primary {
  font-family: var(--font-mark);
  font-weight: 700;
  font-size: clamp(42px, 6.4vw, 64px);
  letter-spacing: 0.195em;
  line-height: 0.92;
  padding-left: 0.195em;
  color: var(--ink);
  transition: color var(--theme-t) var(--ease);
}

.wordmark-secondary {
  font-family: var(--font-ui);
  font-weight: 450;
  font-size: 13px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 0.42em;
  margin-top: 8px;
  transition: color var(--theme-t) var(--ease);
}

.tagline {
  margin: 22px 0 0;
  font-size: 15px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: -0.01em;
  transition: color var(--theme-t) var(--ease);
}

/* Search — isolated above the quiet layer */
.stage {
  grid-row: 2;
  align-self: start;
  display: flex;
  justify-content: center;
  width: 100%;
  position: relative;
  z-index: 3;
}

.search-cluster {
  position: relative;
  width: var(--search-w);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.search-shell {
  position: relative;
  z-index: 4;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 52px;
  padding: 0 6px 0 4px;
  background: var(--shell);
  border: 0;
  border-radius: 10px;
  box-shadow: none;
  outline: none;
  transition: background-color var(--theme-t) var(--ease);
}

.search-shell:hover,
.page.is-near .search-shell,
.page.is-focused .search-shell {
  border: 0;
  box-shadow: none;
}

.search-input {
  flex: 1;
  min-width: 0;
  height: 50px;
  border: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  letter-spacing: -0.014em;
  outline: none;
  padding: 0 8px 0 4px;
  transition: color var(--theme-t) var(--ease);
}

.search-input::placeholder {
  color: var(--mute-2);
}

.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.icon-btn[hidden] {
  display: none !important;
}

.icon-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  cursor: pointer;
  transition: color 220ms var(--ease), background-color 220ms var(--ease);
}

.icon-btn:hover {
  color: var(--ink);
}

.search-icon-btn:hover .icon-search {
  transform: translateX(0.5px);
}

.icon-search {
  display: block;
  transition: transform 240ms var(--ease);
}

.clear-btn:hover {
  background: var(--btn);
  color: var(--ink);
}

.icon-btn:focus-visible,
.footer-nav a:focus-visible,
.panel-close:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.search-input:focus-visible {
  outline: none;
}

/* Focus Field — quiet the world, keep the field sharp */
.page.is-near .quiet,
.page.is-near .quiet-part {
  opacity: 0.72;
  filter: blur(calc(var(--blur) * 0.45));
}

.page.is-focused .quiet,
.page.is-focused .quiet-part {
  opacity: 0.42;
  filter: blur(var(--blur));
}

.page.is-focused .ambient {
  opacity: 0.28;
}

/* Footer */
.site-footer {
  grid-row: 3;
  align-self: end;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  margin: 0;
  padding: 16px 0 20px;
  border-top: 1px solid var(--line);
  transition:
    opacity var(--t) var(--ease),
    filter var(--t) var(--ease),
    border-color var(--theme-t) var(--ease);
}

.footer-nav {
  display: flex;
  gap: 22px;
}

.footer-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  letter-spacing: 0.01em;
  transition: color var(--theme-t) var(--ease);
}

.footer-nav a:hover {
  color: var(--ink);
}

.copyright {
  margin: 0;
  color: var(--mute-2);
  font-size: 12px;
  transition: color var(--theme-t) var(--ease);
}

.footer-mark {
  font-family: var(--font-mark);
  font-weight: 650;
  letter-spacing: 0.18em;
  font-size: 11px;
}

.panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--panel-veil);
}

.panel:target {
  display: flex;
}

.panel-card {
  width: min(420px, 100%);
  background: var(--bg-lift);
  border: 0;
  border-radius: 12px;
  padding: 28px 28px 22px;
}

.panel-card h2 {
  margin: 0 0 10px;
  font-family: var(--font-mark);
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.panel-card p {
  margin: 0 0 22px;
  color: var(--ink-soft);
  font-size: 14.5px;
}

.panel-close {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.panel-close:hover {
  color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .ambient {
    opacity: 0.28;
  }

  .page.is-near .quiet,
  .page.is-near .quiet-part,
  .page.is-focused .quiet,
  .page.is-focused .quiet-part {
    filter: none;
    opacity: 0.7;
  }
}

@media (max-width: 720px) {
  :root {
    --pad-x: 18px;
    --search-w: min(612px, calc(100vw - 36px));
    --blur: 3.5px;
  }

  .theme-toggle {
    top: 10px;
    right: 10px;
  }

  .ambient {
    width: 168px;
    height: 30px;
    margin-bottom: 16px;
  }

  .ambient canvas {
    width: 168px;
    height: 30px;
  }

  .wordmark-primary {
    font-size: 40px;
    letter-spacing: 0.16em;
    padding-left: 0.16em;
  }

  .wordmark-secondary {
    letter-spacing: 0.34em;
    padding-left: 0.34em;
    font-size: 12px;
  }

  .tagline {
    font-size: 14px;
    margin-top: 16px;
  }

  .masthead {
    padding-bottom: 22px;
  }

  .search-shell {
    height: 50px;
  }

  .site-footer {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-bottom: 28px;
  }
}

@media (max-width: 420px) {
  .wordmark-primary {
    font-size: 34px;
  }
}

@media (max-height: 700px) {
  .ambient {
    margin-bottom: 12px;
  }

  .masthead {
    padding-bottom: 16px;
  }

  .tagline {
    margin-top: 12px;
  }
}

@media (min-width: 1100px) and (min-height: 800px) {
  .wordmark-primary {
    font-size: 68px;
  }
}

/* Results */
.results-body {
  min-height: 100dvh;
}

.results-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 24px 12px;
  border-bottom: 1px solid var(--line);
}

.results-mark {
  font-family: var(--font-mark);
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--ink);
  text-decoration: none;
  font-size: 15px;
  padding-left: 0.18em;
}

.results-form {
  flex: 1;
  max-width: 640px;
}

.results-shell {
  height: 44px;
}

.results-theme {
  position: static;
}

.results-main {
  width: min(720px, calc(100% - 48px));
  margin: 0 auto;
  padding: 22px 0 64px;
}

.results-meta {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 18px;
}

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

.result {
  margin: 0 0 26px;
}

.result-url {
  color: var(--muted);
  font-size: 12.5px;
  margin-bottom: 4px;
}

.result-title {
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
  display: inline-block;
}

.result-title:hover {
  text-decoration: underline;
}

.result-snippet {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
}

.result-snippet mark {
  background: transparent;
  color: var(--ink);
  font-weight: 600;
}

.results-pager {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

.results-pager a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.results-pager a:hover {
  color: var(--ink);
}

@media (max-width: 720px) {
  .results-bar {
    flex-wrap: wrap;
    padding: 12px 16px;
  }
  .results-form {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
}
