/* ═══════════════════════════════════════════════
   CIRO — Global Stylesheet
   Shared variables, reset, typography, evidence board
   ═══════════════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&family=Caveat:wght@400;500&family=Courier+Prime:ital@0;1&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,300;1,400&family=Dancing+Script:wght@400;500;600;700&display=swap');

/* ── CSS Custom Properties ── */
:root {
  /* Landing / Global Navigation */
  --landing-bg: #1a1815;
  --landing-text: #e8e2d6;
  --landing-muted: rgba(200, 192, 180, 0.6);
  --landing-faint: rgba(180, 170, 150, 0.08);
  --landing-accent: rgba(180, 90, 90, 0.6);
  --landing-accent-strong: rgba(200, 110, 110, 0.8);

  /* Ettore Fontana — light, warm, golden */
  --ettore-bg: #f5f0e6;
  --ettore-text: #3a3428;
  --ettore-muted: rgba(70, 60, 42, 0.7);
  --ettore-accent: rgba(160, 140, 90, 1);
  --ettore-accent-faint: rgba(160, 140, 90, 0.22);
  --ettore-label: rgba(140, 120, 70, 0.75);

  /* Il Diario di Ciro — warm, earthy, intimate */
  --diario-bg: #2c2820;
  --diario-text: #e0d8c8;
  --diario-muted: rgba(215, 208, 195, 0.55);
  --diario-accent: rgba(190, 165, 120, 1);
  --diario-accent-faint: rgba(166, 142, 100, 0.1);
  --diario-label: rgba(190, 165, 120, 0.45);

  /* L'Archivio di Flaminia — dark, institutional, red-accented */
  --archivio-bg: #1c1a17;
  --archivio-text: #ddd8cc;
  --archivio-muted: rgba(200, 192, 180, 0.45);
  --archivio-accent: rgba(180, 90, 90, 1);
  --archivio-accent-faint: rgba(139, 69, 69, 0.3);
  --archivio-label: rgba(170, 85, 85, 0.6);

  /* Typography */
  --font-display: 'Cormorant Garamond', 'Georgia', serif;
  --font-mono: 'Courier Prime', 'Courier New', monospace;
  --font-hand: 'Caveat', cursive;
  --font-hand-flaminia: 'Dancing Script', cursive;
  --font-body: 'DM Sans', 'Helvetica Neue', sans-serif;

  /* Spacing */
  --space-xs: 8px;
  --space-sm: 16px;
  --space-md: 32px;
  --space-lg: 48px;
  --space-xl: 80px;
  --space-2xl: 120px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.6s var(--ease-out);
  --transition-med: 0.4s var(--ease-out);
  --transition-fast: 0.2s ease;
}

/* ── Skip link ── */
.skip-link {
  position: absolute;
  top: -3rem;
  left: 0;
  background: #1a1815;
  color: #ede8de;
  padding: 0.5rem 1rem;
  text-decoration: none;
  z-index: 1000;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}
.skip-link:focus {
  top: 0;
}

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

html {
  scroll-behavior: smooth;
  font-size: 100%; /* 16px base — all rem units scale from here */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  background: var(--landing-bg);
  color: var(--landing-text);
  overflow-x: hidden;
  line-height: 1.6;
}

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

a {
  text-decoration: none;
  color: inherit;
}

button {
  font: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

/* ── Utility: Staggered fade-up ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes breathe {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50%      { opacity: 0.65; transform: translateY(5px); }
}

@keyframes subtlePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180, 90, 90, 0); }
  50%      { box-shadow: 0 0 12px 2px rgba(180, 90, 90, 0.15); }
}

.fade-up {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}

.fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Evidence Board Icon (persistent, all pages) ── */
.evidence-board-toggle {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 1000;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(28, 26, 23, 0.9);
  border: 1px solid rgba(180, 170, 150, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-med);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.evidence-board-toggle:hover {
  border-color: rgba(180, 170, 150, 0.35);
  transform: scale(1.08);
}

.evidence-board-toggle.has-clues {
  animation: subtlePulse 3s ease-in-out infinite;
}

.evidence-board-toggle svg {
  width: 20px;
  height: 20px;
  stroke: rgba(200, 192, 180, 0.6);
  fill: none;
  stroke-width: 1.5;
}

.evidence-board-toggle .clue-count {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: rgba(180, 90, 90, 0.8);
  color: #e8e2d6;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0);
  transition: all var(--transition-fast);
}

.evidence-board-toggle.has-clues .clue-count {
  opacity: 1;
  transform: scale(1);
}

/* ── Evidence Board Panel ── */
.evidence-board-panel {
  position: fixed;
  top: 0;
  right: -480px;
  width: 460px;
  max-width: 90vw;
  height: 100vh;
  z-index: 1001;
  background: #1e1c18;
  border-left: 1px solid rgba(180, 170, 150, 0.18);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: right var(--transition-slow);
  overflow-y: auto;
  padding: 40px 32px;
}

.evidence-board-panel.open {
  right: 0;
}

.evidence-board-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-med);
}

.evidence-board-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.eb-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 36px;
}

.eb-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 300;
  color: var(--landing-text);
  letter-spacing: 0.05em;
}

.eb-subtitle {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.125em;
  text-transform: uppercase;
  color: rgba(200, 192, 180, 0.55);
  margin-top: 0.375rem;
}

.eb-close {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(200, 192, 180, 0.5);
  font-size: 1.5rem;
  transition: color var(--transition-fast);
}

.eb-close:hover {
  color: rgba(200, 192, 180, 0.85);
}

.eb-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.eb-column-label {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(200, 192, 180, 0.65);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(180, 170, 150, 0.08);
  margin-bottom: 1rem;
}

.eb-clue {
  padding: 0.875rem;
  margin-bottom: 0.75rem;
  background: rgba(40, 36, 30, 0.6);
  border: 1px solid rgba(180, 170, 150, 0.1);
  border-radius: 2px;
  animation: fadeUp 0.4s var(--ease-out) both;
  position: relative;
}

.eb-clue-source {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.125em;
  text-transform: uppercase;
  color: rgba(200, 192, 180, 0.5);
  margin-bottom: 0.375rem;
}

.eb-clue-text {
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.6;
  color: rgba(225, 218, 200, 0.85);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.eb-clue-remove {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  color: rgba(200, 192, 180, 0.3);
  cursor: pointer;
  transition: color var(--transition-fast);
  background: none;
  border: none;
  padding: 0;
}

.eb-clue-remove:hover {
  color: rgba(200, 192, 180, 0.7);
}

.eb-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3.75rem 1.25rem;
}

.eb-empty-text {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-style: italic;
  color: rgba(200, 192, 180, 0.65);
  line-height: 1.8;
}

/* ── Clue markers (inline in microsites) ── */
.clue-marker {
  position: relative;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 1px solid transparent;
}

.clue-marker:hover {
  border-bottom-color: rgba(180, 170, 150, 0.25);
}

.clue-marker::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(180, 170, 150, 0.1);
  transition: background var(--transition-fast);
}

.clue-marker:hover::after {
  background: rgba(180, 170, 150, 0.3);
}

.clue-marker.pinned {
  opacity: 0.5;
}

.clue-marker.pinned::after {
  background: rgba(180, 90, 90, 0.3);
}

/* ── Toast notification on pin ── */
.clue-toast {
  position: fixed;
  bottom: 5.625rem;
  right: 2rem;
  z-index: 1002;
  background: rgba(28, 26, 23, 0.95);
  border: 1px solid rgba(180, 170, 150, 0.15);
  padding: 0.75rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: rgba(200, 192, 180, 0.8);
  letter-spacing: 0.05em;
  opacity: 0;
  transform: translateY(10px);
  transition: all var(--transition-med);
  pointer-events: none;
}

.clue-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ── Shared back-bar / navigation ── */
.back-bar {
  padding: 16px 40px;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-btn {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.125em;
  color: rgba(200, 192, 180, 0.6);
  cursor: pointer;
  transition: color 0.3s;
  padding: 0.5rem 0;
}

.back-btn:hover {
  color: rgba(200, 192, 180, 0.9);
}

/* Focus visible for keyboard navigation */
.back-btn:focus-visible,
.world-nav a:focus-visible,
.evidence-board-toggle:focus-visible,
.eb-close:focus-visible,
.eb-clue-remove:focus-visible,
.clue-marker:focus-visible {
  outline: 2px solid rgba(200, 192, 180, 0.6);
  outline-offset: 3px;
  border-radius: 2px;
}

.world-nav {
  display: flex;
  gap: 0;
  margin-left: auto;
}

.world-nav a {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.125em;
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  transition: color 0.3s;
  cursor: pointer;
}

/* ── Audio toggle in nav ── */
.audio-toggle {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: transparent;
  border: 1px solid rgba(180, 170, 150, 0.2);
  color: rgba(200, 192, 180, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
  margin-left: 1rem;
  flex-shrink: 0;
  padding: 0;
}

.audio-toggle:hover {
  background: rgba(200, 192, 180, 0.1);
  color: rgba(200, 192, 180, 0.9);
  border-color: rgba(180, 170, 150, 0.4);
}

.audio-toggle:focus-visible {
  outline: 2px solid rgba(200, 192, 180, 0.6);
  outline-offset: 3px;
  border-radius: 50%;
}

.audio-toggle .audio-icon--paused { display: none; }
.audio-toggle .audio-icon--playing { display: block; }
.audio-toggle.is-paused .audio-icon--paused { display: block; }
.audio-toggle.is-paused .audio-icon--playing { display: none; }

/* ── Help toggle in nav ── */
.help-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: transparent;
  border: 1px solid rgba(180, 170, 150, 0.2);
  color: rgba(200, 192, 180, 0.5);
  cursor: pointer;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
  margin-right: 0.5rem;
  flex-shrink: 0;
  padding: 0;
}

.help-toggle:hover {
  background: rgba(200, 192, 180, 0.1);
  color: rgba(200, 192, 180, 0.9);
  border-color: rgba(180, 170, 150, 0.4);
}

.help-toggle:focus-visible {
  outline: 2px solid rgba(200, 192, 180, 0.6);
  outline-offset: 3px;
  border-radius: 50%;
}

/* ── Istruzioni modal (injected by istruzioni.js) ── */
.istruzioni-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(10, 9, 7, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.istruzioni-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.istruzioni-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 2001;
  width: 92vw;
  max-width: 860px;
  max-height: 88vh;
  transform: translate(-50%, -50%) translateY(20px);
  background: #f5f0e6;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(180, 170, 140, 0.06) 3px,
      rgba(180, 170, 140, 0.06) 6px
    );
  border: 1px solid #d4c9b0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  padding: 3.5rem 4rem 3rem;
  color: #2c2218;
}

.istruzioni-modal.open {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -50%) translateY(0);
}

.istruzioni-close {
  position: sticky;
  top: 0;
  float: right;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: #8a7e6c;
  cursor: pointer;
  transition: color 0.3s;
  z-index: 5;
  background: rgba(245, 240, 230, 0.9);
  border-radius: 50%;
  border: none;
}

.istruzioni-close:hover {
  color: #2c2218;
}

.istruzioni-header {
  text-align: center;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(44, 34, 24, 0.1);
}

.istruzioni-icon {
  font-size: 1.5rem;
  color: rgba(180, 90, 90, 0.6);
  margin-bottom: 1rem;
}

.istruzioni-header h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  color: #2c2218;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.istruzioni-sotto {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #8a7e6c;
}

.istruzioni-body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.85;
  color: #3a3028;
}

.istruzioni-body p {
  margin-bottom: 1rem;
}

.istruzioni-body h3 {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 500;
  color: #2c2218;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  letter-spacing: 0.03em;
}

.istruzioni-body ul {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.istruzioni-body ul li {
  padding: 0.5rem 0 0.5rem 1.25rem;
  position: relative;
}

.istruzioni-body ul li::before {
  content: '\2014';
  position: absolute;
  left: 0;
  color: #8a7e6c;
}

.istruzioni-body strong {
  font-weight: 600;
  color: #2c2218;
}

.istruzioni-body em {
  font-style: italic;
}

.istruzioni-faldone-icon,
.istruzioni-help-icon-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: rgba(44, 34, 24, 0.08);
  border: 1.5px solid rgba(44, 34, 24, 0.2);
  border-radius: 6px;
  vertical-align: middle;
  margin: 0 0.2rem;
}

.istruzioni-faldone-icon svg,
.istruzioni-help-icon-inline svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke: #3a3028;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.istruzioni-chiusa {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  font-style: italic;
  color: #8b2e2e;
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(44, 34, 24, 0.1);
}

@media (max-width: 768px) {
  .istruzioni-modal {
    padding: 2.5rem 2rem 2rem;
  }

  .istruzioni-header h2 {
    font-size: 1.5rem;
  }

  .istruzioni-body {
    font-size: 1rem;
  }
}

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 1.5rem 2.5rem;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  letter-spacing: 0.125em;
  color: rgba(215, 208, 195, 0.55);
  background: var(--landing-bg);
  line-height: 1.8;
}

.site-footer.footer-sticky {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.site-footer.footer-sticky.footer-visible {
  opacity: 1;
  transform: translateY(0);
}

.site-footer a {
  color: rgba(215, 208, 195, 0.7);
  text-decoration: none;
  transition: color 0.3s;
}

.site-footer a:hover {
  color: rgba(215, 208, 195, 0.95);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .evidence-board-toggle {
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
  }

  .evidence-board-panel {
    width: 100vw;
    max-width: 100vw;
    right: -100vw;
    padding: 32px 24px;
  }

  .eb-columns {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .back-bar {
    padding: 12px 20px;
  }

  .world-nav a {
    padding: 0.5rem 0.625rem;
    font-size: 0.75rem;
  }

  .clue-toast {
    right: 20px;
    bottom: 74px;
  }
}
