:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #6b675f;
  --line: #e4e0d6;
  --accent: #0b6e4f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .06);
  --calciomercato: #0a5cad;
  --sportmediaset: #d4232b;
  --gazzetta: #e5007e;
  --radius: 14px;
}
:root[data-theme="dark"] {
  --bg: #14140f;
  --surface: #1e1d18;
  --text: #ece9e2;
  --muted: #a19c91;
  --line: #2e2c25;
  --accent: #4cc497;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .35);
  --calciomercato: #5aa2ec;
  --sportmediaset: #ff6168;
  --gazzetta: #ff5cb4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14140f;
    --surface: #1e1d18;
    --text: #ece9e2;
    --muted: #a19c91;
    --line: #2e2c25;
    --accent: #4cc497;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .35);
    --calciomercato: #5aa2ec;
    --sportmediaset: #ff6168;
    --gazzetta: #ff5cb4;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 Inter, system-ui, -apple-system, sans-serif;
}
a { color: inherit; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Masthead */
.masthead {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.masthead-inner { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 18px; padding-bottom: 10px; }
.brand { margin: 0; font: 700 clamp(1.6rem, 4vw, 2.3rem)/1.1 Fraunces, Georgia, serif; letter-spacing: -.02em; }
.tagline { margin: 4px 0 0; color: var(--muted); font-size: .88rem; }
.actions { display: flex; gap: 8px; flex-shrink: 0; }

.btn, .icon-btn {
  font: 500 .9rem Inter, sans-serif;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.icon-btn { padding: 8px 12px; }
a.btn { text-decoration: none; display: inline-block; }
.btn:hover, .icon-btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; }

.toolbar { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }
.tab {
  flex-shrink: 0;
  font: 500 .88rem Inter, sans-serif;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.tab .count { opacity: .7; margin-left: 4px; font-size: .8em; }
.search {
  flex: 0 1 280px; min-width: 0; width: 100%;
  font: inherit; font-size: .92rem;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
}
.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

main { padding-top: 24px; padding-bottom: 32px; }

/* Source badge */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 .72rem Inter, sans-serif; text-transform: uppercase; letter-spacing: .06em;
  color: var(--src);
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--src); }
[data-source="calciomercato"] { --src: var(--calciomercato); }
[data-source="sportmediaset"] { --src: var(--sportmediaset); }
[data-source="gazzetta"] { --src: var(--gazzetta); }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--muted); font-size: .8rem; }
.cat { text-transform: uppercase; letter-spacing: .04em; font-size: .72rem; font-weight: 600; }

/* Hero */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 28px; align-items: center;
  background: var(--surface); border-radius: calc(var(--radius) + 4px); overflow: hidden;
  box-shadow: var(--shadow); text-decoration: none; margin-bottom: 32px;
}
/* The photo fills the card's height (cropped), never pushing into the text column. */
.hero .thumb { aspect-ratio: auto; align-self: stretch; min-height: 320px; }
.hero .body { padding: 24px 28px 24px 0; }
.hero h2 { font: 700 clamp(1.4rem, 3vw, 2.1rem)/1.15 Fraunces, Georgia, serif; margin: 10px 0 12px; letter-spacing: -.01em; }
.hero p { color: var(--muted); margin: 0 0 14px; font-size: 1.02rem; }
.hero:hover h2 { color: var(--accent); }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 24px; }
.card, .hero, .hero .body { min-width: 0; overflow-wrap: break-word; }
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-3px); }
.card:hover h3 { color: var(--accent); }
.card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { margin: 0; font: 600 1.08rem/1.3 Fraunces, Georgia, serif; }
.card p {
  margin: 0; color: var(--muted); font-size: .9rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card .meta { margin-top: auto; padding-top: 4px; }

.thumb { position: relative; aspect-ratio: 16/9; background: color-mix(in srgb, var(--src) 14%, var(--surface)); overflow: hidden; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.card:hover .thumb img, .hero:hover .thumb img { transform: scale(1.04); }
.thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; font: 700 1.4rem Fraunces, serif; color: var(--src); opacity: .55; }

/* Skeleton */
.skeleton .thumb, .skeleton .line { background: linear-gradient(90deg, var(--line), var(--surface), var(--line)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.skeleton .line { height: 12px; border-radius: 6px; margin: 4px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

.errors { background: color-mix(in srgb, #d4232b 10%, var(--surface)); border: 1px solid color-mix(in srgb, #d4232b 35%, transparent); border-radius: 10px; padding: 10px 14px; margin-bottom: 20px; font-size: .88rem; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.more { text-align: center; margin-top: 32px; }
/* Spacing lives on the button so it disappears when the button is hidden. */
.more .btn { margin-bottom: 40px; }
.footer { color: var(--muted); font-size: .82rem; padding-top: 20px; padding-bottom: 40px; border-top: 1px solid var(--line); }

@media (max-width: 760px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .hero .body { padding: 16px 18px 20px; }
  .hero .thumb { aspect-ratio: 16/9; min-height: 0; }
  .search { flex-basis: 100%; }
  .btn { padding: 8px 12px; }
  .grid { gap: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---- Reader ------------------------------------------------------------ */
body.reading { overflow: hidden; }
.reader {
  --reader-scale: 1;
  position: fixed; inset: 0; z-index: 50;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface);
  animation: reader-in .28s ease-out;
}
.reader[hidden] { display: none; }
@keyframes reader-in { from { opacity: 0; transform: translateY(16px); } }

.reader-progress { position: sticky; top: 0; height: 3px; z-index: 2; }
.reader-progress span { display: block; height: 100%; width: 0; background: var(--src, var(--accent)); transition: width .1s linear; }
.reader-bar {
  position: sticky; top: 3px; z-index: 1;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.reader-bar-inner { max-width: 1000px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 12px; }
.reader-bar-title {
  flex: 1; min-width: 0; font-weight: 600; font-size: .9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity .2s;
}
.reader.scrolled .reader-bar-title { opacity: 1; }
.reader-bar .actions { margin-left: auto; }

.reader-article { max-width: 720px; margin: 0 auto; padding: 40px 16px 80px; }
.r-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 18px; }
.r-title {
  font: 700 clamp(1.9rem, 5vw, 3rem)/1.1 Fraunces, Georgia, serif;
  letter-spacing: -.02em; margin: 0 0 18px; overflow-wrap: break-word;
}
.r-standfirst {
  font: 400 calc(1.25rem * var(--reader-scale))/1.5 "Source Serif 4", Georgia, serif;
  color: var(--muted); margin: 0 0 24px;
}
.r-byline {
  display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center;
  font-size: .88rem; color: var(--muted);
  padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.r-byline strong { color: var(--text); font-weight: 600; }
.r-byline .dot::before { content: "·"; }
.r-hero { margin: 28px -16px 32px; }
.r-hero img { width: 100%; max-height: 520px; object-fit: cover; display: block; background: var(--line); }
@media (min-width: 760px) {
  .r-hero { margin: 32px -80px 40px; }
  .r-hero img { border-radius: var(--radius); }
}

.r-body {
  font: 400 calc(1.16rem * var(--reader-scale))/1.75 "Source Serif 4", Georgia, serif;
  color: var(--text);
  overflow-wrap: break-word;
}
.r-body > p:first-of-type::first-letter {
  float: left; font: 700 3.6em/.8 Fraunces, Georgia, serif;
  padding: .08em .1em 0 0; color: var(--src, var(--accent));
}
.r-body p { margin: 0 0 1.25em; }
.r-body h2, .r-body h3 {
  font: 700 .95em/1.3 Inter, sans-serif; text-transform: uppercase; letter-spacing: .05em;
  color: var(--src, var(--accent)); margin: 2em 0 .8em;
}
.r-body h2 { font-size: 1.05em; }
.r-body a { color: inherit; text-decoration-color: var(--src, var(--accent)); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.r-body a:hover { color: var(--src, var(--accent)); }
.r-body strong { font-weight: 600; }
.r-body blockquote {
  margin: 1.6em 0; padding: .2em 0 .2em 1.2em;
  border-left: 3px solid var(--src, var(--accent));
  font-style: italic; font-size: 1.1em; color: var(--muted);
}
.r-body ul, .r-body ol { padding-left: 1.3em; margin: 0 0 1.25em; }
.r-body li { margin-bottom: .4em; }
.r-body figure { margin: 1.8em 0; }
.r-body img { max-width: 100%; height: auto; border-radius: 10px; display: block; margin: 0 auto; }
.r-body figcaption { font: .8rem/1.4 Inter, sans-serif; color: var(--muted); margin-top: 6px; }

.r-note {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: color-mix(in srgb, var(--src, var(--accent)) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--src, var(--accent)) 25%, transparent);
  border-radius: 12px; padding: 14px 16px; margin: 0 0 28px; font-size: .92rem;
}
.r-end { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); text-align: center; }
.r-end .src-link { font-size: .88rem; color: var(--muted); }
.r-end .src-link a { color: var(--src, var(--accent)); font-weight: 600; text-decoration: none; }
.r-next { margin-top: 48px; }
.r-next h4 { font: 600 .75rem Inter, sans-serif; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 14px; }
.r-next-list { display: grid; gap: 14px; }
.r-next-item {
  display: grid; grid-template-columns: 112px 1fr; gap: 14px; align-items: center;
  text-decoration: none; padding: 10px; margin: 0 -10px; border-radius: 12px;
}
.r-next-item:hover { background: var(--bg); }
.r-next-item:hover b { color: var(--accent); }
.r-next-item .thumb { aspect-ratio: 4/3; border-radius: 8px; }
.r-next-item b { font: 600 1rem/1.3 Fraunces, Georgia, serif; display: block; margin-bottom: 4px; }

.r-skel .line { height: 1.05em; margin: .7em 0; border-radius: 6px; background: linear-gradient(90deg, var(--line), var(--surface), var(--line)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }

/* ---- Legal pages --------------------------------------------------------- */
.brand-link { text-decoration: none; }
.legal { max-width: 720px; margin: 0 auto; padding: 32px 16px 56px; font: 400 1.08rem/1.7 "Source Serif 4", Georgia, serif; }
.legal h1 { font: 700 clamp(1.8rem, 5vw, 2.6rem)/1.15 Fraunces, Georgia, serif; letter-spacing: -.02em; margin: 0 0 16px; }
.legal h2 { font: 600 .82rem/1.3 Inter, sans-serif; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin: 2.2em 0 .7em; }
.legal p, .legal li { margin: 0 0 1em; }
.legal ul { padding-left: 1.2em; }
.legal a { color: var(--accent); }
.legal code { font-size: .88em; background: var(--line); padding: 1px 5px; border-radius: 4px; }
.legal-lead { font-size: 1.15rem; color: var(--muted); }
.legal-updated { font: .85rem Inter, sans-serif; color: var(--muted); }
.legal mark { background: #fff1a8; color: #3a3000; padding: 0 3px; border-radius: 3px; }
.contact-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; margin: 8px 0 12px;
}
.contact-label { flex-basis: 100%; font: 600 .72rem Inter, sans-serif; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.legal .contact-email { font: 700 clamp(1.2rem, 4vw, 1.5rem)/1.2 Fraunces, Georgia, serif; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.legal .contact-email:hover { color: var(--accent); }
.legal .contact-btn { margin-left: auto; color: var(--bg); background: var(--text); border-color: var(--text); }
@media (max-width: 520px) { .legal .contact-btn { margin-left: 0; } }
