/* ============================================================
   SearchMister — main stylesheet
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: #f0f4f8;
  color: #202124;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

a { color: #1a0dab; text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid #1a73e8; outline-offset: 2px; border-radius: 2px; }

img { display: block; max-width: 100%; height: auto; }

/* ── Site header (results pages only) ────────────────────── */
.site-header {
  background: #ffffff;
  border-bottom: 1px solid #dadce0;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.site-header__logo {
  font-size: 1.2rem;
  font-weight: 300;
  color: #202124;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: -.2px;
}
.site-header__logo strong { font-weight: 700; color: #1a73e8; }
.site-header__logo:hover  { text-decoration: none; color: #202124; }

/* ── Search form ──────────────────────────────────────────── */
.search-form--header { flex: 1; max-width: 580px; }
.search-form--hero   { width: 100%; max-width: 560px; margin: 28px auto 0; }

.search-form__wrap {
  display: flex;
  border: 1px solid #dadce0;
  border-radius: 24px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  transition: box-shadow .15s, border-color .15s;
}
.search-form__wrap:focus-within {
  border-color: #1a73e8;
  box-shadow: 0 2px 8px rgba(26,115,232,.15);
}

.search-form__input {
  flex: 1;
  border: none;
  outline: none;
  padding: 11px 18px;
  font-size: 1rem;
  color: #202124;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}
.search-form__input::placeholder { color: #9aa0a6; }

/* Remove native clear button in IE/Edge */
.search-form__input::-ms-clear { display: none; }

.search-form__btn {
  flex-shrink: 0;
  border: none;
  border-left: 1px solid #dadce0;
  background: #1a73e8;
  color: #ffffff;
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 0 22px;
  cursor: pointer;
  transition: background .15s;
}
.search-form__btn:hover  { background: #1558b0; }
.search-form__btn:active { background: #1246a0; }

/* ── Home hero ────────────────────────────────────────────── */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 90px 20px 70px;
  text-align: center;
  flex: 1;
}

.hero__brand {
  display: block;
  font-size: 3rem;
  font-weight: 300;
  color: #202124;
  letter-spacing: -.5px;
  line-height: 1;
}
.hero__brand strong { font-weight: 700; color: #1a73e8; }

.hero__tagline {
  display: block;
  font-size: .9rem;
  color: #5f6368;
  margin-top: 6px;
}

/* ── Layout wrapper ───────────────────────────────────────── */
.layout {
  display: flex;
  flex: 1;
  align-items: flex-start;
}

.layout--home {
  justify-content: center;
}

/* ── Sidebars ─────────────────────────────────────────────── */
.sidebar {
  width: 210px;
  flex-shrink: 0;
  padding: 20px 12px;
  min-height: 1px;   /* keep the column even when empty */
}

.sidebar__inner {
  /* placeholder — content added in phase 2 */
}

/* ── Main content column ──────────────────────────────────── */
.content {
  flex: 1;
  padding: 18px 16px;
  min-width: 0;         /* prevent flex overflow */
  max-width: 720px;
}

/* ── Results meta line ────────────────────────────────────── */
.results-meta {
  font-size: .82rem;
  color: #5f6368;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e8eaed;
}
.results-meta em { font-style: normal; color: #202124; font-weight: 500; }

/* ── Notices ──────────────────────────────────────────────── */
.notice {
  font-size: .95rem;
  color: #5f6368;
  padding: 10px 0;
}
.notice--error { color: #c5221f; }
.notice em { font-style: normal; font-weight: 500; }

/* ── Card base ────────────────────────────────────────────── */
.card {
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 1px 5px rgba(0,0,0,.10);
  overflow: hidden;
  margin-bottom: 18px;
}

/* ── Wikipedia card specifics ─────────────────────────────── */
.card--wiki {
  border-left: 4px solid #3366cc;
}

.card__head {
  padding: 12px 16px 2px;
}

.card__source-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  font-weight: 700;
  color: #3366cc;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.card__source-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Card body: text left, image right ────────────────────── */
.card__body {
  display: flex;
  gap: 16px;
  padding: 10px 16px 16px;
  align-items: flex-start;
}

/* Image goes to the right via order */
.card__figure {
  order: 2;
  flex-shrink: 0;
  margin: 0;
}

.card__thumb {
  width: 180px;
  height: auto;
  max-height: 220px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e8eaed;
}

.card__text {
  order: 1;
  flex: 1;
  min-width: 0;
}

.card__title {
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 4px;
}
.card__title a { color: #1a0dab; }
.card__title a:hover { text-decoration: underline; }

.card__desc {
  font-size: .82rem;
  color: #5f6368;
  font-style: italic;
  margin-bottom: 10px;
}

.card__extract {
  font-size: .93rem;
  line-height: 1.65;
  color: #3c4043;
  margin-bottom: 12px;
  /* Clamp to ~6 lines */
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__readmore {
  display: inline-block;
  font-size: .84rem;
  font-weight: 500;
  color: #1a73e8;
  padding: 5px 12px;
  border: 1px solid #1a73e8;
  border-radius: 20px;
  transition: background .15s, color .15s;
}
.card__readmore:hover {
  background: #1a73e8;
  color: #fff;
  text-decoration: none;
}

/* ── Related articles section ─────────────────────────────── */
.card__related {
  background: #f8f9fa;
  border-top: 1px solid #e8eaed;
  padding: 14px 16px 16px;
}

.card__related-title {
  font-size: .72rem;
  font-weight: 700;
  color: #5f6368;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 10px;
}

.card__related-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card__related-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.card__related-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid #e8eaed;
  margin-top: 1px;
}

.card__related-text {
  flex: 1;
  min-width: 0;
}

.card__related-text a {
  font-size: .88rem;
  font-weight: 500;
  color: #1a0dab;
  display: block;
  line-height: 1.3;
}
.card__related-text a:hover { text-decoration: underline; }

.card__related-desc {
  display: block;
  font-size: .78rem;
  color: #5f6368;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  background: #ffffff;
  border-top: 1px solid #dadce0;
  padding: 16px 20px;
  font-size: .78rem;
  color: #5f6368;
  text-align: center;
  margin-top: auto;
}
.site-footer a { color: #5f6368; }
.site-footer a:hover { color: #1a73e8; text-decoration: underline; }

/* ── Responsive ───────────────────────────────────────────── */

/* Narrow desktop: shrink sidebars */
@media (max-width: 960px) {
  .sidebar { width: 160px; }
}

/* Tablet / mobile */
@media (max-width: 700px) {
  .layout--results {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding: 10px 14px 0;
  }

  /* Hide empty right sidebar on small screens */
  .sidebar--right { display: none; }

  /* Stack image below text on mobile */
  .card__body { flex-direction: column; }
  .card__figure { order: 0; }
  .card__thumb  { width: 100%; max-height: 200px; }

  .hero { padding: 60px 16px 48px; }
  .hero__brand { font-size: 2.2rem; }
}
