/* Base */
:root {
  --bg: #0b1020;
  --fg: #e2e8f0;
  --muted: #94a3b8;
  --link: var(--fg);
  --surface: #0f172a;
  --border: #1e293b;
}
:root.light {
  --bg: #ffffff;
  --fg: #0f172a;
  --muted: #334155;
  --link: var(--fg);
  --surface: #f8fafc;
  --border: #e2e8f0;
}

/* Dark esplicito */
:root.dark {
  --bg: #000000;
  --fg: #ffffff;
  --muted: #ffffff;
  --link: var(--fg);
  --surface: #0a0a0a;
  --border: #222222;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Chivo Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 300;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--fg);
  transition: background 200ms, color 200ms;
}

/* Layout */
.container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.header, .footer, .sections, .lead {
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  padding: 0 1rem;
}
.header { margin-top: 2rem; display: flex; align-items: center; justify-content: space-between; }
.title { font-size: 1.5rem; font-weight: 300; margin: 0; }
.lead { margin: 2rem auto 1.75rem; color: var(--muted); }
.lead a.underline-link { color: var(--fg); border-bottom: 1px solid var(--fg); text-decoration: none; }
.lead a.underline-link:hover { opacity: .85; }

/* Sections */
.sections { padding-bottom: 3rem; }
.block { margin-bottom: 1.5rem; }

.block-title {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: 1rem;
  font-weight: 300;
  user-select: none;
}
.block-title .caret { 
  font-size: .9rem; 
  transform: translateY(-1px); 
  margin-right: .25rem;         /* spazio prima di [ */
}

.research-quote {
  font-family: 'Space Mono', monospace;
  font-weight: 400;
  font-style: italic;
}

.block-content {
  padding-left: 1.25rem;
  border-left: 1px solid var(--border);
  margin-top: .5rem;
}
.block-content[data-collapsed="true"] { display: none; }

.inner { display: grid; gap: .5rem; color: var(--muted); }
.list { margin: .25rem 0 0; padding-left: 1rem; }
.list li { margin: .25rem 0; }

a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
a:visited, a:hover, a:active { color: var(--link); }
a.underline-link { text-decoration: underline; text-underline-offset: 3px; }

/* Bold text styling */
b, strong { font-weight: 600; }

/* Footer */
.footer {
  margin-top: auto;
  padding: 2rem 1rem;
  color: var(--muted);
  text-align: left;
  border-top: 1px solid var(--border);
}

/* Terminal-style footer */
.terminal-footer{
  margin: 0;
  padding: 0;
  font: inherit;
  color: var(--muted);
  white-space: pre-wrap;
  line-height: 1.35;
  font-size: 0.75rem;
  opacity: 0.8;
}

/* Small flair */
.fade-in { animation: fade .4s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(2px)} to { opacity: 1; transform: none } }
.height-text { line-height: 1.6; }
.text-ui-1 { color: var(--fg); }
.text-ui-2 { color: var(--muted); }

/* === Theme Switch === */
#theme-switch{
  height: 40px;
  width: 40px;
  padding: 0;
  border-radius: 999px;
  background-color: var(--surface);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 0;
  cursor: pointer;
  transition: background 150ms;
}
#theme-switch:hover { background-color: var(--border); }
#theme-switch svg { fill: var(--fg); }

/* mostra luna di default, nasconde sole */
#theme-switch svg:last-child{ display:none; }
/* in dark mostra il sole, nasconde la luna */
:root.dark #theme-switch svg:first-child{ display:none; }
:root.dark #theme-switch svg:last-child{ display:block; }

/* Blinking caret next to the title */
.title .cursor{
  display: inline-block;
  width: .6ch;
  height: 1em;
  background: var(--fg);
  margin-left: .25ch;
  animation: caret-blink 1s steps(1, end) infinite;
  vertical-align: -.1em;
}
@keyframes caret-blink{
  0%,49% { opacity: 1; }
  50%,100% { opacity: 0; }
}

/* === Fake system log line === */
.syslog{
  max-width: 48rem;
  margin: .5rem auto 0;
  padding: 0 1rem;
  font: inherit;          /* usa la monospace del sito */
  color: var(--muted);
  opacity: .9;
  line-height: 1.4;
  min-height: 1.2em;      /* evita layout shift quando cambia il testo */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Fade-in leggero ad ogni update */
.syslog.fade{
  animation: syslog-fade .35s ease;
}
@keyframes syslog-fade{
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: .9; transform: none; }
}

/* Rispetta chi chiede meno animazioni */
@media (prefers-reduced-motion: reduce){
  .syslog.fade{ animation: none; }
}

.syslog {
  width: 100%;
  max-width: 48rem;       /* stessa larghezza di lead/sections */
  margin: 0.75rem auto 1.5rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--muted);
  background: var(--surface);
  border-left: 2px solid var(--border);
  border-radius: 3px;
  line-height: 1.3;
  opacity: 0.85;
}
.syslog.fade {
  animation: syslog-fade .35s ease;
}
@keyframes syslog-fade {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 0.85; transform: none; }
}

/* === Mini console overlay === */
.console.hidden{ display:none; }
.console{
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  z-index: 2000;
}
.console-panel{
  width: min(640px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  font: inherit;
}
.console-output{
  margin: 0 0 .75rem 0;
  color: var(--muted);
  font: inherit;
  white-space: pre-wrap;
  line-height: 1.4;
  max-height: 40vh;
  overflow: auto;
}
.console-input-wrap{
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: .5rem;
  border-top: 1px solid var(--border);
  padding-top: .5rem;
}
.console-input-wrap .prompt{
  color: var(--fg);
  opacity: .8;
}
#console-input{
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font: inherit;
  padding: .25rem 0;
}

/* ==== Mini-terminal tooltip ==== */
.tipterm {
  position: relative;
  cursor: help;
  border-bottom: 1px dashed var(--muted);
}

/* contenitore popup riutilizzabile creato via JS */
.tipterm-pop {
  position: absolute;
  left: 0;
  top: 125%;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .5rem .65rem;
  font-family: 'Chivo Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .8rem;
  line-height: 1.35;
  white-space: pre-wrap;
  box-shadow: 0 10px 24px rgba(0,0,0,.28);
  min-width: 240px;
  max-width: min(420px, 80vw);
  z-index: 30;
  opacity: 0;
  transform: translateY(2px);
  pointer-events: none;            /* niente intercetto del mouse */
  transition: opacity .12s ease, transform .12s ease;
}

/* piccola freccia */
.tipterm-pop::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 12px;
  border: 6px solid transparent;
  border-bottom-color: var(--border);
}
.tipterm-pop::after {
  content: "";
  position: absolute;
  top: -5px;
  left: 12px;
  border: 5px solid transparent;
  border-bottom-color: var(--surface);
}

/* prompt stile terminal */
.tipterm-pop .tipline {
  display: block;
}
.tipterm-pop .prompt {
  color: var(--muted);
  margin-right: .5ch;
}

/* stato visibile */
.tipterm-pop.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* rispetto preferenze utente */
@media (prefers-reduced-motion: reduce) {
  .tipterm-pop { transition: none; }
}