/* ========================================
   Hub Didattico Interattivo — Design System
   ======================================== */

/* --- Tokens --- */
:root, [data-theme='light'] {
  --font-display: 'Chillax', 'Arial', sans-serif;
  --font-body: 'Nunito', 'Helvetica Neue', sans-serif;

  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;
  --space-16: 4rem; --space-20: 5rem; --space-24: 6rem;

  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-surface-2: #f0f4f8;
  --color-border: #d0d7e0;
  --color-divider: #e2e8f0;
  --color-text: #1a2a3a;
  --color-text-muted: #5a6a7a;
  --color-text-faint: #94a3b8;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-primary-dark: #1e40af;
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-error: #dc2626;
  --color-error-light: #fee2e2;
  --color-warning: #d97706;
  --color-warning-light: #fef3c7;
  --color-accent: #0d9488;
  --color-accent-light: #ccfbf1;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.25rem;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04);

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --content-default: 960px;

  /* Phase Colors */
  --engage: #f59e0b;
  --engage-light: #fef3c7;
  --explore: #8b5cf6;
  --explore-light: #ede9fe;
  --explain: #2563eb;
  --explain-light: #dbeafe;
  --elaborate: #0d9488;
  --elaborate-light: #ccfbf1;
  --evaluate: #16a34a;
  --evaluate-light: #dcfce7;
}

[data-theme='dark'] {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-surface-2: #283548;
  --color-border: #334155;
  --color-divider: #1e293b;
  --color-text: #e2e8f0;
  --color-text-muted: #94a3b8;
  --color-text-faint: #64748b;
  --color-primary: #60a5fa;
  --color-primary-hover: #3b82f6;
  --color-primary-light: #1e3a5f;
  --color-primary-dark: #93c5fd;
  --color-success: #4ade80;
  --color-success-light: #14532d;
  --color-error: #f87171;
  --color-error-light: #450a0a;
  --color-warning: #fbbf24;
  --color-warning-light: #451a03;
  --color-accent: #2dd4bf;
  --color-accent-light: #134e4a;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.05);

  --engage: #fbbf24;
  --engage-light: #451a03;
  --explore: #a78bfa;
  --explore-light: #2e1065;
  --explain: #60a5fa;
  --explain-light: #1e3a5f;
  --elaborate: #2dd4bf;
  --elaborate-light: #134e4a;
  --evaluate: #4ade80;
  --evaluate-light: #14532d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-surface-2: #283548;
    --color-border: #334155;
    --color-divider: #1e293b;
    --color-text: #e2e8f0;
    --color-text-muted: #94a3b8;
    --color-text-faint: #64748b;
    --color-primary: #60a5fa;
    --color-primary-hover: #3b82f6;
    --color-primary-light: #1e3a5f;
    --color-primary-dark: #93c5fd;
    --color-success: #4ade80;
    --color-success-light: #14532d;
    --color-error: #f87171;
    --color-error-light: #450a0a;
    --color-warning: #fbbf24;
    --color-warning-light: #451a03;
    --color-accent: #2dd4bf;
    --color-accent-light: #134e4a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.05);
    --engage: #fbbf24;
    --engage-light: #451a03;
    --explore: #a78bfa;
    --explore-light: #2e1065;
    --explain: #60a5fa;
    --explain-light: #1e3a5f;
    --elaborate: #2dd4bf;
    --elaborate-light: #134e4a;
    --evaluate: #4ade80;
    --evaluate-light: #14532d;
  }
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-16);
}
body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body, sans-serif);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
}
img, svg { display: block; max-width: 100%; height: auto; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
a { text-decoration: none; color: inherit; }
a, button, [role='button'] {
  transition: color var(--transition-interactive), background var(--transition-interactive),
    border-color var(--transition-interactive), box-shadow var(--transition-interactive),
    transform var(--transition-interactive);
}
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; border-radius: var(--radius-sm); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.header-inner {
  max-width: var(--content-default);
  margin: 0 auto;
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.logo-area {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.logo-icon {
  color: var(--color-primary);
  flex-shrink: 0;
}
.site-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.2;
}
.site-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.3;
}
.theme-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
}
.theme-toggle:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

/* --- Hero --- */
.hero {
  background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-surface) 50%, var(--color-accent-light) 100%);
  border-bottom: 1px solid var(--color-divider);
}
.hero-inner {
  max-width: var(--content-default);
  margin: 0 auto;
  padding: var(--space-12) var(--space-6) var(--space-10);
  text-align: center;
}
.hero-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary);
  background: var(--color-surface);
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-primary);
  margin-bottom: var(--space-6);
}
.hero-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: var(--space-4);
  color: var(--color-text);
}
.hero-desc {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 640px;
  margin: 0 auto var(--space-8);
  line-height: 1.7;
}
.hero-desc strong {
  color: var(--color-text);
  font-weight: 700;
}
.hero-meta {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  flex-wrap: wrap;
}
.meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.meta-item svg {
  color: var(--color-primary);
  flex-shrink: 0;
}

/* --- TIC Section --- */
.tic-section {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
}
.tic-inner {
  max-width: var(--content-default);
  margin: 0 auto;
  padding: var(--space-6);
  text-align: center;
}
.section-label {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-faint);
  margin-bottom: var(--space-4);
}
.tic-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}
.tic-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-divider);
}
.tic-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot-color);
  flex-shrink: 0;
}

/* --- Phases --- */
.phases-section {
  padding: var(--space-10) 0 var(--space-16);
}
.phases-inner {
  max-width: var(--content-default);
  margin: 0 auto;
  padding: 0 var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

/* Phase Block */
.phase-block {
  position: relative;
}
.phase-block::before {
  content: '';
  position: absolute;
  top: 44px;
  left: 23px;
  bottom: -32px;
  width: 2px;
  background: var(--color-divider);
}
.phase-block:last-child::before {
  display: none;
}
.phase-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.phase-number {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
[data-phase="engage"] .phase-number { background: var(--engage); }
[data-phase="explore"] .phase-number { background: var(--explore); }
[data-phase="explain"] .phase-number { background: var(--explain); }
[data-phase="elaborate"] .phase-number { background: var(--elaborate); }
[data-phase="evaluate"] .phase-number { background: var(--evaluate); }

.phase-label {
  display: inline-block;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-1);
}
.phase-label.engage { color: var(--engage); background: var(--engage-light); }
.phase-label.explore { color: var(--explore); background: var(--explore-light); }
.phase-label.explain { color: var(--explain); background: var(--explain-light); }
.phase-label.elaborate { color: var(--elaborate); background: var(--elaborate-light); }
.phase-label.evaluate { color: var(--evaluate); background: var(--evaluate-light); }

.phase-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.phase-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 50ch;
}

/* App Cards */
.phase-apps {
  padding-left: calc(48px + var(--space-4));
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.app-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.app-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 60%, var(--color-primary-light) 100%);
  opacity: 0;
  transition: opacity var(--transition-normal);
}
.app-card:hover::before {
  opacity: 1;
}
.app-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.app-card:active {
  transform: translateY(0);
}
.app-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  color: var(--color-primary);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.app-content {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.app-tic-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-1);
}
.app-tic-badge.wordwall { color: #0d9488; background: #ccfbf1; }
.app-tic-badge.learningapps { color: #d97706; background: #fef3c7; }
.app-tic-badge.genially { color: #16a34a; background: #dcfce7; }
.app-tic-badge.kahoot { color: #dc2626; background: #fee2e2; }
.app-tic-badge.edcivica { color: #7c3aed; background: #ede9fe; }

[data-theme='dark'] .app-tic-badge.wordwall { color: #2dd4bf; background: #134e4a; }
[data-theme='dark'] .app-tic-badge.learningapps { color: #fbbf24; background: #451a03; }
[data-theme='dark'] .app-tic-badge.genially { color: #4ade80; background: #14532d; }
[data-theme='dark'] .app-tic-badge.kahoot { color: #f87171; background: #450a0a; }
[data-theme='dark'] .app-tic-badge.edcivica { color: #a78bfa; background: #2e1065; }

.app-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.app-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}
.app-arrow {
  color: var(--color-text-faint);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: transform var(--transition-interactive);
}
.app-card:hover .app-arrow {
  color: var(--color-primary);
  transform: translateX(4px);
}

/* --- Footer --- */
.footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-divider);
  padding: var(--space-8) var(--space-6);
}
.footer-inner {
  max-width: var(--content-default);
  margin: 0 auto;
  text-align: center;
}
.footer-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.footer-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
}
.footer-badges {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.footer-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
}

/* --- Animations --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.phase-block {
  animation: fadeInUp 0.5s ease both;
}
.phase-block:nth-child(1) { animation-delay: 0.1s; }
.phase-block:nth-child(2) { animation-delay: 0.2s; }
.phase-block:nth-child(3) { animation-delay: 0.3s; }
.phase-block:nth-child(4) { animation-delay: 0.4s; }
.phase-block:nth-child(5) { animation-delay: 0.5s; }

/* --- Responsive --- */
@media (max-width: 640px) {
  .header-inner {
    padding: var(--space-3) var(--space-4);
  }
  .site-subtitle {
    display: none;
  }
  .hero-inner {
    padding: var(--space-8) var(--space-4) var(--space-8);
  }
  .hero-title {
    font-size: var(--text-xl);
  }
  .hero-meta {
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
  }
  .phase-block::before {
    left: 19px;
    top: 40px;
  }
  .phase-number {
    width: 40px;
    height: 40px;
    font-size: var(--text-base);
  }
  .phase-apps {
    padding-left: calc(40px + var(--space-3));
  }
  .app-card {
    padding: var(--space-4);
    gap: var(--space-3);
    flex-direction: column;
    align-items: flex-start;
  }
  .app-icon {
    width: 44px;
    height: 44px;
  }
  .app-arrow {
    display: none;
  }
  .tic-chip {
    font-size: var(--text-xs);
  }
  .footer-inner {
    padding: 0 var(--space-4);
  }
}
