/* ==========================================================================
   giacomogaggero.it — foglio di stile globale
   Palette definita su :root (light) e ridefinita per il dark mode.
   ========================================================================== */

:root {
  --bg:            #ffffff;
  --bg-soft:       #f6f7f9;
  --bg-elevated:   #ffffff;
  --text:          #1b1f24;
  --text-muted:    #5a6472;
  --border:        #e2e6ec;
  --accent:        #1f4e79;
  --accent-soft:   #eaf1f8;
  --accent-hover:  #16395a;
  --shadow:        0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);

  /* Verde/rosso del Market Outlook, allineati alla palette di market_sentinel */
  --pos:           #15a05a;
  --pos-soft:      #e8f6ee;
  --neg:           #d8443b;
  --neg-soft:      #fdecea;

  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;

  --maxw: 62rem;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0f1419;
    --bg-soft:     #151b22;
    --bg-elevated: #171e26;
    --text:        #e6eaf0;
    --text-muted:  #9aa6b4;
    --border:      #262f3a;
    --accent:      #7db3e8;
    --accent-soft: #16283b;
    --accent-hover:#a3ccf2;
    --shadow:      0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    --pos:         #3fc484;
    --pos-soft:    #102c1f;
    --neg:         #f2695f;
    --neg-soft:    #331715;
  }
}

:root[data-theme="dark"] {
  --bg:          #0f1419;
  --bg-soft:     #151b22;
  --bg-elevated: #171e26;
  --text:        #e6eaf0;
  --text-muted:  #9aa6b4;
  --border:      #262f3a;
  --accent:      #7db3e8;
  --accent-soft: #16283b;
  --accent-hover:#a3ccf2;
  --shadow:      0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  --pos:         #3fc484;
  --pos-soft:    #102c1f;
  --neg:         #f2695f;
  --neg-soft:    #331715;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  margin: 0 0 .6em;
}

h1 { font-size: clamp(2rem, 5vw, 2.9rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.4rem, 3vw, 1.75rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1.1em; }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 1.5rem;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff;
  padding: .6rem 1rem; z-index: 200; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* ---------- Header / navigazione ---------- */

.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg); /* fallback per browser senza color-mix() */
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: 4rem;
}

.brand {
  font-family: var(--font-serif);
  font-size: 1.2rem; font-weight: 600;
  color: var(--text); text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--accent); text-decoration: none; }

.nav { display: flex; align-items: center; gap: .15rem; }

.nav a {
  color: var(--text-muted);
  font-size: .93rem;
  padding: .45rem .7rem;
  border-radius: 6px;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 500; }

.header-tools { display: flex; align-items: center; gap: .35rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.2rem; height: 2.2rem;
  background: none; border: 1px solid transparent; border-radius: 6px;
  color: var(--text-muted); cursor: pointer; padding: 0;
}
.icon-btn:hover { color: var(--text); background: var(--bg-soft); border-color: var(--border); }
.icon-btn svg { width: 1.15rem; height: 1.15rem; }

#nav-toggle { display: none; }

/* L'icona mostrata è quella del tema attivo: sole in chiaro, luna in scuro. */
.theme-icon-light { display: block; }
.theme-icon-dark  { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-light { display: none; }
  :root:not([data-theme="light"]) .theme-icon-dark  { display: block; }
}

:root[data-theme="dark"] .theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-dark  { display: block; }
:root[data-theme="light"] .theme-icon-light { display: block; }
:root[data-theme="light"] .theme-icon-dark  { display: none; }

@media (max-width: 820px) {
  #nav-toggle { display: inline-flex; }
  .nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch;
    background: var(--bg); border-bottom: 1px solid var(--border);
    padding: .5rem 1.5rem 1rem; gap: 0;
    box-shadow: var(--shadow);
  }
  .nav:not(.is-open) { display: none; }
  .nav a { padding: .7rem .5rem; font-size: 1rem; }
}

/* ---------- Hero (home) ---------- */

.hero {
  padding: clamp(3rem, 9vw, 6rem) 0 clamp(2rem, 5vw, 3.5rem);
  border-bottom: 1px solid var(--border);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(1.5rem, 5vw, 3.5rem);
  align-items: center;
}

.hero h1 { margin-bottom: .35em; }

.hero .subtitle {
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  color: var(--text-muted);
  margin-bottom: 1.6rem;
  max-width: 34rem;
}
.hero .subtitle strong { color: var(--text); font-weight: 600; }

.portrait {
  width: clamp(150px, 24vw, 230px);
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--bg-soft);
}

@media (max-width: 700px) {
  .hero-grid { grid-template-columns: 1fr; justify-items: start; }
  .hero-grid .portrait { order: -1; }
}

/* ---------- Bottoni / link sociali ---------- */

.link-row { display: flex; flex-wrap: wrap; gap: .6rem; }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem .95rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-elevated); color: var(--text);
  font-size: .9rem; font-weight: 500;
  text-decoration: none;
  transition: border-color .15s, color .15s, background .15s;
}
.btn:hover {
  color: var(--accent); border-color: var(--accent);
  background: var(--accent-soft); text-decoration: none;
}
.btn svg { width: 1.05rem; height: 1.05rem; flex: none; }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .btn-primary:hover { color: #0f1419; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary,
  :root:not([data-theme="light"]) .btn-primary:hover { color: #0f1419; }
}

/* ---------- Corpo pagina ---------- */

main { flex: 1 0 auto; }

.page-head {
  padding: clamp(2.5rem, 6vw, 4rem) 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}
.page-head h1 { margin-bottom: .25em; }
.page-head .lead { color: var(--text-muted); margin: 0; max-width: 46rem; }

section { margin-bottom: 3.5rem; }

.section-label {
  font-family: var(--font-sans);
  font-size: .78rem; font-weight: 600;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 1.2rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--border);
}

/* ---------- Card contenuto ---------- */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem clamp(1.1rem, 3vw, 1.75rem);
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.card > :last-child { margin-bottom: 0; }

.card h3 { margin-bottom: .5rem; font-size: 1.1rem; line-height: 1.4; }
.card h3 a { color: var(--text); }
.card h3 a:hover { color: var(--accent); }

.meta {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.meta em { font-style: normal; color: var(--text); font-weight: 500; }

.abstract { margin-top: 1rem; }

.abstract > summary {
  cursor: pointer;
  font-size: .85rem; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent);
  list-style: none;
  display: inline-flex; align-items: center; gap: .4rem;
}
.abstract > summary::-webkit-details-marker { display: none; }
.abstract > summary::before {
  content: "▸";
  display: inline-block;
  transition: transform .15s ease;
  font-size: .9em;
}
.abstract[open] > summary::before { transform: rotate(90deg); }
.abstract > summary:hover { color: var(--accent-hover); }

.abstract p {
  margin: .9rem 0 0;
  font-size: .95rem;
  color: var(--text-muted);
  text-align: justify;
  hyphens: auto;
}

/* Elenco chiave/valore per le conferenze */
.details {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: .3rem 1rem;
  margin: 0 0 1rem;
  font-size: .93rem;
}
.details dt {
  color: var(--text-muted);
  font-size: .8rem; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase;
  padding-top: .12rem;
}
.details dd { margin: 0; min-width: 0; }

@media (max-width: 560px) {
  .details { grid-template-columns: 1fr; gap: .1rem; }
  .details dd { margin-bottom: .55rem; }
}

.quote {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-muted);
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  margin: 0 0 1rem;
}

.year-tag {
  display: inline-block;
  font-size: .78rem; font-weight: 600; letter-spacing: .06em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: .18rem .65rem;
  margin-bottom: .9rem;
}

.prose ul { padding-left: 1.2rem; margin: 0 0 1.1em; }
.prose li { margin-bottom: .5rem; }

/* ---------- Pagina Book ---------- */

.book-grid {
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}
.book-cover {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  background: var(--bg-soft);
}
@media (max-width: 700px) {
  .book-grid { grid-template-columns: 1fr; }
  .book-cover { max-width: 240px; }
}

/* ==========================================================================
   Market Outlook
   Il markup di questa sezione è rigenerato ogni giorno feriale da
   market_sentinel/maillist_services/generate_outlook.py, che inietta il
   frammento nel segnaposto di market-outlook.template.html.
   Cambiando queste classi, allinea anche genera_fragment_sito() nello script.
   ========================================================================== */

/* Riga dei quattro contatori */
.ol-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2.5rem;
}

.ol-kpi {
  background: var(--bg-elevated);
  padding: 1.1rem 1rem;
  text-align: center;
}

.ol-kpi-label {
  display: block;
  font-size: .68rem; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .45rem;
}

.ol-kpi-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.75rem; font-weight: 700;
  line-height: 1;
}

.ol-kpi-buy  .ol-kpi-value { color: var(--pos); }
.ol-kpi-sell .ol-kpi-value { color: var(--neg); }

@media (max-width: 620px) {
  .ol-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ol-kpi-value { font-size: 1.5rem; }
}

/* Articolo generato */
.ol-article {
  max-width: 44rem;
  font-size: 1.02rem;
  line-height: 1.8;
}
.ol-article p { margin: 0 0 1.2em; }
.ol-article p:last-child { margin-bottom: 0; }
.ol-article strong { font-weight: 600; color: var(--text); }

/* Tabelle degli strumenti */
.ol-tables { margin-top: 3rem; }

.ol-table-title {
  font-family: var(--font-sans);
  font-size: .78rem; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
  margin: 2.5rem 0 .75rem;
}
.ol-tables > .ol-table-title:first-child { margin-top: 0; }
.ol-table-title.ol-buy  { color: var(--pos); }
.ol-table-title.ol-sell { color: var(--neg); }

/* Contenitore che scrolla da solo: la pagina non scorre mai in orizzontale */
.ol-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}

.ol-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  min-width: 30rem;
}

.ol-table th {
  text-align: left;
  padding: .65rem .9rem;
  font-size: .68rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.ol-table td {
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.ol-table tbody tr:last-child td { border-bottom: 0; }
.ol-table tbody tr:hover td { background: var(--bg-soft); }

.ol-table .ol-ticker {
  font-family: var(--font-mono);
  font-weight: 700;
  white-space: nowrap;
}
.ol-buy  .ol-ticker, td.ol-ticker.ol-buy  { color: var(--pos); }
.ol-sell .ol-ticker, td.ol-ticker.ol-sell { color: var(--neg); }

.ol-table .ol-num,
.ol-table .ol-right { text-align: right; white-space: nowrap; }
.ol-table .ol-num {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-muted);
}
.ol-table .ol-market { color: var(--text-muted); font-size: .85rem; }

/* Stato "nessuno strumento" e fallback pre-prima-generazione */
.ol-empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-soft);
}
.ol-empty p:last-child { margin-bottom: 0; }

/* Nota su fonte dati e natura automatica dell'analisi */
.ol-disclaimer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: .85rem;
  color: var(--text-muted);
}

.ol-updated {
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--text-muted);
}

.embed-note {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: .8rem;
}

/* ---------- Footer ---------- */

.site-footer {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 2.5rem 0;
  margin-top: 3rem;
  font-size: .9rem;
  color: var(--text-muted);
}
.site-footer .container {
  display: flex; flex-wrap: wrap; gap: 1rem;
  align-items: center; justify-content: space-between;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 1.1rem; }
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }

/* ---------- Utility ---------- */

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

@media print {
  .site-header, .site-footer, .icon-btn { display: none; }
  .abstract[open] > summary { display: none; }
  body { font-size: 11pt; }
  .card { break-inside: avoid; box-shadow: none; }
}
