/* ============================================
   Cerulean Search — Styles
   Clean, minimal, cerulean-branded
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

:root {
  --cerulean:     #007BA7;
  --cerulean-l:   #2A9FCA;
  --cerulean-xl:  #E8F4F9;
  --cerulean-d:   #005F80;
  --ink:          #1A1A2E;
  --body:         #3C4257;
  --muted:        #8993A4;
  --faint:        #C1C8D4;
  --bg:           #FFFFFF;
  --surface:      #F7F9FC;
  --line:         #E8ECF1;
  --radius:       24px;
  --radius-sm:    12px;
  --shadow-s:     0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-m:     0 4px 16px rgba(0,0,0,0.08);
  --shadow-focus: 0 0 0 3px rgba(0,123,167,0.18);
  --font:         'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ease:         cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Dark Mode (manual toggle) ---- */
html.dark {
  --cerulean:     #22d3ee;
  --cerulean-l:   #67e8f9;
  --cerulean-xl:  rgba(34, 211, 238, 0.1);
  --cerulean-d:   #a5f3fc;
  --ink:          #e4e6eb;
  --body:         #c0c5d0;
  --muted:        #7a8394;
  --faint:        #3d4455;
  --bg:           #0f1117;
  --surface:      #1a1d27;
  --line:         #252a36;
  --shadow-s:     0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-m:     0 4px 16px rgba(0,0,0,0.4);
  --shadow-focus: 0 0 0 3px rgba(34,211,238,0.2);
}

/* ---- Auto dark for OS preference ---- */
@media (prefers-color-scheme: dark) {
  :root:not(.light-forced) {
    --cerulean:     #22d3ee;
    --cerulean-l:   #67e8f9;
    --cerulean-xl:  rgba(34, 211, 238, 0.1);
    --cerulean-d:   #a5f3fc;
    --ink:          #e4e6eb;
    --body:         #c0c5d0;
    --muted:        #7a8394;
    --faint:        #3d4455;
    --bg:           #0f1117;
    --surface:      #1a1d27;
    --line:         #252a36;
    --shadow-s:     0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-m:     0 4px 16px rgba(0,0,0,0.4);
    --shadow-focus: 0 0 0 3px rgba(34,211,238,0.2);
  }
}

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

html { height: 100%; }

body {
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  color: var(--body);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

/* ---- Dark Mode Toggle Button ---- */
#dark-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 999;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-s);
  transition: border-color 0.2s, transform 0.15s, background 0.3s;
}
#dark-toggle:hover {
  border-color: var(--cerulean-l);
  transform: scale(1.08);
}

/* ---- App container ---- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: all 0.35s var(--ease);
}

/* ---- LANDING STATE (centered) ---- */
.app.landing {
  justify-content: center;
  align-items: center;
}
.app.landing .main {
  width: 100%;
  max-width: 620px;
  padding: 0 24px;
}
.app.landing .results-header { display: none; }
.app.landing .footer { position: fixed; bottom: 0; left: 0; right: 0; }

/* ---- RESULTS STATE (top-aligned) ---- */
.app.has-results {
  justify-content: flex-start;
  align-items: stretch;
}
.app.has-results .landing-header { display: none; }
.app.has-results .results-header { display: flex; }
.app.has-results .main {
  max-width: 720px;
  padding: 0 24px 60px;
  margin: 0 auto;
  width: 100%;
}
.app.has-results .footer {
  position: fixed; bottom: 0; left: 0; right: 0;
}

/* ---- Landing Header ---- */
.landing-header {
  text-align: center;
  margin-bottom: 36px;
  animation: fadeUp 0.5s var(--ease) both;
}

.wordmark {
  font-size: 56px;
  font-weight: 600;
  letter-spacing: -1.5px;
  color: var(--cerulean);
  user-select: none;
}
.wordmark span {
  display: inline-block;
  animation: letterPop 0.5s var(--ease) both;
}
.wm-c  { animation-delay: 0.02s; }
.wm-e  { animation-delay: 0.05s; }
.wm-r  { animation-delay: 0.08s; }
.wm-u  { animation-delay: 0.11s; }
.wm-l  { animation-delay: 0.14s; }
.wm-e2 { animation-delay: 0.17s; }
.wm-a  { animation-delay: 0.20s; }
.wm-n  { animation-delay: 0.23s; }

@keyframes letterPop {
  0%   { opacity: 0; transform: translateY(12px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeUp {
  0%   { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}

.tagline {
  font-size: 14px;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 400;
}

/* ---- Results Header (top bar) ---- */
.results-header {
  display: none;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.home-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}

.mini-wordmark {
  font-family: var(--font);
  font-size: 22px;
  font-weight: 600;
  color: var(--cerulean);
  letter-spacing: -0.5px;
}

/* ---- Search Bar ---- */
.search-container {
  animation: fadeUp 0.4s var(--ease) 0.1s both;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 6px 4px 16px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.3s;
}
.search-bar:hover {
  border-color: var(--faint);
  box-shadow: var(--shadow-s);
}
.search-bar:focus-within {
  border-color: var(--cerulean);
  box-shadow: var(--shadow-focus);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  font-family: var(--font);
  padding: 12px 12px;
  color: var(--ink);
  background: transparent;
}
.search-bar input::placeholder {
  color: var(--faint);
}

.search-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--cerulean);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.search-btn svg {
  width: 18px;
  height: 18px;
}
.search-btn:hover {
  background: var(--cerulean-d);
}
.search-btn:active {
  transform: scale(0.95);
}
html.dark .search-btn {
  color: #0f1117;
}

/* ---- Filter Chips ---- */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 0 4px;
  animation: fadeUp 0.3s var(--ease) both;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  user-select: none;
}
.chip:hover {
  border-color: var(--cerulean-l);
  color: var(--cerulean);
}
.chip.active {
  background: var(--cerulean-xl);
  border-color: rgba(0,123,167,0.3);
  color: var(--cerulean);
}
html.dark .chip.active {
  border-color: rgba(34, 211, 238, 0.3);
}
.chip svg { opacity: 0.7; }
.chip.active svg { opacity: 1; }

.provider-select {
  margin-left: auto;
}
.provider-select select {
  font-family: var(--font);
  font-size: 12.5px;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer;
  outline: none;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}
.provider-select select:focus {
  border-color: var(--cerulean-l);
}

/* ---- Status ---- */
.status {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 4px 0;
}
.status.searching {
  color: var(--cerulean);
}

/* ---- Synthesis ---- */
.synthesis {
  background: var(--cerulean-xl);
  border: 1px solid rgba(0,123,167,0.15);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-top: 8px;
  animation: fadeUp 0.3s var(--ease) both;
}
html.dark .synthesis {
  border-color: rgba(34, 211, 238, 0.15);
}
.synthesis h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--cerulean-d);
  margin-bottom: 10px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.synthesis ul {
  list-style: none;
  padding: 0;
}
.synthesis li {
  font-size: 14px;
  color: var(--body);
  line-height: 1.55;
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}
.synthesis li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cerulean-l);
}
.synthesis .cites {
  color: var(--muted);
  font-size: 11px;
  margin-left: 4px;
}

/* ---- Results ---- */
.results {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 8px;
}

.result {
  padding: 16px 4px;
  border-bottom: 1px solid var(--line);
  animation: fadeUp 0.25s var(--ease) both;
}
.result:last-child { border-bottom: none; }

.result .cite-url {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result .title {
  margin: 0;
}
.result .title a {
  font-size: 18px;
  font-weight: 500;
  color: var(--cerulean);
  text-decoration: none;
  line-height: 1.35;
}
.result .title a:visited {
  color: #6B21A8;
}
html.dark .result .title a:visited {
  color: #c084fc;
}
.result .title a:hover {
  text-decoration: underline;
}

.result .snippet {
  font-size: 14px;
  color: var(--body);
  line-height: 1.55;
  margin-top: 4px;
}

.result .meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.result .score-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--cerulean);
  background: var(--cerulean-xl);
  padding: 2px 8px;
  border-radius: 999px;
}

.result .date-badge {
  font-size: 11px;
  color: var(--muted);
}

.result .reasons {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}
.result .pill {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
}

.no-results {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
  font-size: 15px;
}

/* ---- Footer ---- */
.footer {
  text-align: center;
  padding: 14px;
  font-size: 12px;
  color: var(--faint);
  background: var(--bg);
  border-top: 1px solid var(--line);
  transition: background 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease);
}

/* ---- Loading spinner ---- */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--cerulean-xl);
  border-top-color: var(--cerulean);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Hidden utility ---- */
.hidden { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .wordmark { font-size: 40px; }
  .search-bar { border-radius: 18px; }
  .app.has-results .main { padding: 0 16px 60px; }
  .filters { gap: 6px; }
  .chip { font-size: 11.5px; padding: 5px 10px; }
  .result .title a { font-size: 16px; }
}
