/* Ozbit News - two themes, one file.
   Light (default): a newspaper. Warm paper background, black ink, serif
   headlines, thin and double rules, no pills, gradients or shadows.
   Dark: the same layout on a dark slate background with a blue accent.
   The theme is switched with the moon/sun button in the header; main.js
   applies the saved choice (or the OS preference) as data-theme on <html>. */

:root {
  --news-bg: #fbf8f1;
  --news-ink: #1a1a1a;
  --news-body: #33302a;
  --news-muted: #6f6a5c;
  --news-rule: #1a1a1a;
  --news-rule-light: #d9d2bf;
  --news-accent: #1d4ed8;
  --news-accent-light: #3b82f6;
  --news-image-bg: #efe9db;
  --news-masthead-rule: 3px double #1a1a1a;
  --news-featured-rule: 3px double #1a1a1a;
}

:root[data-theme='dark'] {
  --news-bg: #0f172a;
  --news-ink: #e2e8f0;
  --news-body: #cbd5e1;
  --news-muted: #94a3b8;
  --news-rule: #e2e8f0;
  --news-rule-light: #334155;
  --news-accent: #60a5fa;
  --news-accent-light: #93c5fd;
  --news-image-bg: #1e293b;
  --news-masthead-rule: 1px solid #334155;
  --news-featured-rule: 2px solid #60a5fa;
}

body {
  background: var(--news-bg);
  color: var(--news-body);
}

/* Top bar: small logo left, section links right, theme button, thin rule */
.header {
  background: var(--news-bg);
  border-bottom: 1px solid var(--news-rule-light);
  box-shadow: none;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav__logo a {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--news-ink);
  text-decoration: none;
}

.nav__link {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--news-body);
}

.nav__link:hover {
  color: var(--news-accent);
}

/* Active topic in the mobile menu: underlined, like the desktop nav. */
.nav__mobile-link.nav__mobile-link--active {
  color: var(--news-accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--news-rule-light);
  border-radius: 50%;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--news-muted);
  cursor: pointer;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.theme-toggle:hover {
  color: var(--news-accent);
  border-color: var(--news-accent);
}

/* Masthead */
.news-hero {
  background: var(--news-bg);
  color: var(--news-ink);
  text-align: center;
  padding: var(--spacing-10) 0 var(--spacing-6);
  border-bottom: var(--news-masthead-rule);
}

.news-hero__title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(2.75rem, 8vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 0;
  color: var(--news-ink);
}

.news-hero__date {
  margin-top: var(--spacing-3);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--news-muted);
}

/* Topic title: a plain text identifier naming the topic being viewed.
   The top menu is the only selector now — this heading just says where
   you are, in the same serif as the masthead, with a double rule. */
.news-topic {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  margin: 0 0 var(--spacing-4);
  padding: var(--spacing-4) 0;
  color: var(--news-ink);
  border-bottom: 3px double var(--news-rule);
}

.news-status {
  text-align: center;
  color: var(--news-muted);
  padding: var(--spacing-8) 0;
}

.news-retry {
  display: block;
  margin: var(--spacing-4) auto 0;
}

/* .btn sets display:inline-flex, which beats the hidden attribute's
   display:none — without this the button stays visible even when the
   feed has loaded. */
.news-retry[hidden] {
  display: none !important;
}

/* Article grid: three columns, flat cards separated by light rules */
.news-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-8) var(--spacing-6);
  padding-bottom: var(--spacing-12);
}

.news-card {
  background: var(--news-bg);
  border: none;
  border-top: 1px solid var(--news-rule-light);
  border-radius: 0;
  padding: var(--spacing-5) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
}

.news-card__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  margin-bottom: var(--spacing-2);
  background: var(--news-image-bg);
}

.news-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  flex: 1;
}

.news-card--featured {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--spacing-8);
  align-items: start;
  border-top: var(--news-featured-rule);
  padding-top: var(--spacing-6);
}

.news-card--featured .news-card__image {
  margin-bottom: 0;
}

.news-card__badge {
  align-self: flex-start;
  color: var(--news-accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0;
  background: none;
  border-radius: 0;
}

.news-card__title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.25;
}

.news-card__title a {
  color: var(--news-ink);
  text-decoration: none;
}

.news-card__title a:hover {
  color: var(--news-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.news-card--featured .news-card__title {
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
}

.news-card__description {
  color: var(--news-body);
  font-size: 0.95rem;
  line-height: 1.6;
  flex: 1;
}

.news-card__meta {
  color: var(--news-muted);
  font-size: 0.8rem;
}

.news-card__link {
  color: var(--news-accent);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}

.news-card__link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.news-card__links {
  display: flex;
  gap: var(--spacing-6);
  flex-wrap: wrap;
}

.news-note {
  color: var(--news-muted);
  font-size: var(--font-size-sm);
  text-align: center;
  padding-bottom: var(--spacing-12);
}

/* Footer: same paper as the page in light mode, dark slate in dark mode.
   The author name links to the CV page (opens in a new tab). */
.footer {
  background: var(--news-bg);
  color: var(--news-body);
  border-top: 1px solid var(--news-rule-light);
}

.footer a {
  color: var(--news-accent);
}

.footer__copyright {
  color: var(--news-muted);
}

.footer__author {
  color: var(--news-ink);
  font-weight: var(--font-weight-semibold);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer__author:hover {
  color: var(--news-accent);
}

@media (max-width: 900px) {
  .news-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .news-card--featured {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .news-grid {
    grid-template-columns: 1fr;
  }

  .news-card--featured {
    grid-column: auto;
  }
}

/* Search (this topic, or all topics on Global): a single ruled line,
   newspaper style, with a "Clear" text button at its right end. */
.news-search {
  position: relative;
  max-width: 28rem;
  margin: 0 auto var(--spacing-6);
}

.news-search__clear {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  min-height: 2.25rem;
  padding: 0 0.25rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--news-accent);
  background: none;
  border: 0;
  cursor: pointer;
}

.news-search__clear:hover {
  text-decoration: underline;
}

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

/* The browser's own small x would duplicate "Clear". */
.news-search__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.news-search__input {
  width: 100%;
  padding: var(--spacing-2) 0;
  font: inherit;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1rem;
  text-align: center;
  color: var(--news-ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--news-rule-light);
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  /* Room for "Clear" on both sides keeps the text centred. */
  padding-left: 4rem;
  padding-right: 4rem;
}

.news-search__input::placeholder {
  color: var(--news-muted);
  font-style: italic;
}

.news-search__input:focus {
  outline: none;
  border-bottom-color: var(--news-accent);
}

.news-search__summary {
  text-align: center;
  color: var(--news-muted);
  font-size: var(--font-size-sm);
  margin: calc(-1 * var(--spacing-2)) 0 var(--spacing-6);
}

/* "Other outlets": the same story from other publishers. Quieter than
   the main link — a second route, not the story itself. */
.news-card__link--other {
  color: var(--news-muted);
  font-weight: 600;
}

/* Topic label on search results, which mix all five topics. */
.news-card__topic {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: var(--spacing-2);
}

/* 404 page */
.notfound {
  max-width: 36rem;
  margin: 0 auto;
  padding: 4rem 1rem;
  text-align: center;
}

.notfound__brand a {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--news-ink);
  text-decoration: none;
}

.notfound__title {
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--news-ink);
  border-bottom: 3px double var(--news-rule);
  padding-bottom: 1rem;
  margin: 1.5rem 0;
}

.notfound__links {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.notfound__links a {
  color: var(--news-accent);
  font-weight: 600;
}

/* Mobile menu button: the news page's own ink colour. The base
   stylesheet's --dark flips to near-white when the device is in dark
   mode, which left the icon invisible on the light (paper) theme. */
.nav__toggle {
  color: var(--news-ink);
}

/* "New": a story that arrived since the page was opened. */
.news-card__badge--new {
  color: #b91c1c;
  margin-left: var(--spacing-2);
}

:root[data-theme='dark'] .news-card__badge--new {
  color: #f87171;
}

.news-card--new {
  animation: news-card-arrive 1.2s ease-out;
}

@keyframes news-card-arrive {
  from { background-color: var(--news-image-bg); }
  to { background-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .news-card--new { animation: none; }
}

/* Stock ticker tape (Finance), in the style of quantbite.io's: a thin
   dark strip, prices scrolling right to left, paused on hover. */
.ticker-tape {
  background: #111827;
  color: #f9fafb;
  overflow: hidden;
  border-bottom: 1px solid #1f2937;
}

/* Desktop: sticks under the menu bar (its height is set by tape.js).
   On phones it scrolls away with the page, so the two together don't
   take a large part of a small screen. */
@media (min-width: 768px) {
  .ticker-tape {
    position: sticky;
    top: var(--tape-top, 0);
    z-index: 90;
  }
}

.ticker-tape__track {
  display: flex;
  width: max-content;
  animation: ticker-tape-scroll 60s linear infinite;
}

.ticker-tape:hover .ticker-tape__track,
.ticker-tape:focus-within .ticker-tape__track {
  animation-play-state: paused;
}

.ticker-tape__copy {
  display: flex;
}

.ticker-tape__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.85rem;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
}

.ticker-tape__item:hover,
.ticker-tape__item:focus-visible {
  background: #1f2937;
}

.ticker-tape__symbol {
  font-weight: 700;
}

.ticker-tape__change {
  font-weight: 600;
}

.ticker-tape__change--up {
  color: #4ade80;
}

.ticker-tape__change--down {
  color: #f87171;
}

@keyframes ticker-tape-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-tape__track {
    animation: none;
  }

  .ticker-tape {
    overflow-x: auto;
  }
}

/* Local weather: a newspaper "weather ear". Phones and tablets: under
   the date, centred. Wide screens: boxed at the right of the masthead. */
.weather {
  margin: var(--spacing-4) auto 0;
  max-width: 20rem;
  padding: var(--spacing-3) var(--spacing-4);
  border-top: 1px solid var(--news-rule-light);
  border-bottom: 1px solid var(--news-rule-light);
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--news-body);
  text-align: center;
}

.weather p {
  margin: 0;
}

.weather__head {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--news-muted);
}

.weather__label {
  font-weight: 700;
  color: var(--news-ink);
}

.weather__now {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem;
  margin-top: var(--spacing-1) !important;
}

.weather__icon {
  font-size: 1.5rem;
  line-height: 1;
}

.weather__temp {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--news-ink);
}

.weather__cond {
  font-style: italic;
  font-size: 0.95rem;
}

.weather__detail {
  font-size: 0.8rem;
  color: var(--news-muted);
}

.weather__days {
  display: flex;
  justify-content: center;
  gap: var(--spacing-4);
  list-style: none;
  padding: var(--spacing-2) 0 0;
  margin: var(--spacing-2) 0 0;
  border-top: 1px dotted var(--news-rule-light);
  font-size: 0.75rem;
}

.weather__day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.weather__day-name {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.65rem;
  color: var(--news-muted);
}

.weather__day-icon {
  font-size: 1rem;
}

.weather__precise {
  margin-top: var(--spacing-2);
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 0.72rem;
  color: var(--news-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.weather__precise:disabled {
  color: var(--news-muted);
  text-decoration: none;
  cursor: default;
}

@media (min-width: 1024px) {
  /* Three columns: an empty one, the title and date in the middle, the
     weather on the right — so the masthead grows to fit the box. */
  .news-hero__inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    column-gap: var(--spacing-6);
  }

  .news-hero__title {
    grid-column: 2;
    grid-row: 1;
  }

  .news-hero__date {
    grid-column: 2;
    grid-row: 2;
  }

  .weather {
    grid-column: 3;
    grid-row: 1 / span 2;
    justify-self: end;
    margin: 0;
    width: 15rem;
    border: 1px solid var(--news-rule-light);
    text-align: left;
  }

  .weather__head,
  .weather__now {
    justify-content: flex-start;
  }

  .weather__days {
    justify-content: space-between;
  }
}

/* Phones: the first story belongs on the first screen. A tighter
   masthead, the weather as a single line (today only; the 3-day
   forecast and details stay on wider screens), and less space above
   the topic heading. */
@media (max-width: 600px) {
  .news-hero {
    padding: var(--spacing-5) 0 var(--spacing-3);
  }

  .news-hero__title {
    font-size: 2.5rem;
  }

  .news-hero__date {
    margin-top: var(--spacing-2);
  }

  .weather {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    column-gap: 0.75rem;
    row-gap: 0.15rem;
    margin-top: var(--spacing-3);
    padding: var(--spacing-2) 0;
    max-width: none;
  }

  .weather__detail,
  .weather__days {
    display: none;
  }

  .weather__now {
    font-size: 0.95rem;
  }

  .weather__precise {
    flex-basis: 100%;
    margin-top: 0;
  }

  #news.section {
    padding-top: var(--spacing-4);
  }

  .news-topic {
    padding: var(--spacing-2) 0;
    margin-bottom: var(--spacing-3);
  }

  .news-search {
    margin-bottom: var(--spacing-4);
  }
}

/* Finance only: currency converter (js/fx.js). Same newspaper rules as
   the weather box; one row on wide screens, wraps on phones. */
.fx {
  max-width: 40rem;
  margin: 0 auto var(--spacing-6);
  padding: var(--spacing-3) var(--spacing-4);
  border-top: var(--news-masthead-rule);
  border-bottom: 1px solid var(--news-rule-light);
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--news-body);
  text-align: center;
}

.fx p {
  margin: 0;
}

.fx__title {
  margin: 0 0 var(--spacing-2);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--news-muted);
}

.fx__row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.fx__amount,
.fx__select {
  min-height: 2.5rem;
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 1rem;
  color: var(--news-ink);
  background: var(--news-bg);
  border: 1px solid var(--news-rule-light);
  border-radius: 2px;
}

.fx__amount {
  width: 8rem;
  text-align: right;
}

.fx__select {
  max-width: 13rem;
}

.fx__amount:focus,
.fx__select:focus,
.fx__swap:focus-visible {
  outline: 2px solid var(--news-accent);
  outline-offset: 1px;
}

.fx__amount[aria-invalid="true"] {
  border-color: #b91c1c;
}

.fx__swap {
  min-width: 2.5rem;
  min-height: 2.5rem;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--news-accent);
  background: none;
  border: 1px solid var(--news-rule-light);
  border-radius: 2px;
  cursor: pointer;
}

.fx__result {
  margin-top: var(--spacing-3) !important;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--news-ink);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.fx__rate,
.fx__note {
  font-size: 0.85rem;
  color: var(--news-muted);
}

@media (max-width: 600px) {
  .fx {
    margin-bottom: var(--spacing-4);
    padding: var(--spacing-3) 0;
  }

  .fx__amount {
    flex: 1 1 100%;
    width: auto;
    text-align: center;
  }

  .fx__select {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
  }

  .fx__result {
    font-size: 1.25rem;
  }
}
