/* Estils específics per a l'efemèride «El so fa la volta al llac» - INS Pere Borrell */

/* Navegació de l'índex (TOC) en format de píndoles / xips */
.toc {
  margin-top: 2rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
}
.toc a {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: var(--tint);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}
.toc a:hover,
.toc a:focus-visible {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Controls del formulari */
select {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  transition: border-color 0.2s ease;
}
select:focus,
input:focus {
  border-color: var(--primary);
}

/* Indicadors de resultats millorats */
.results div {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 4px solid var(--primary);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.results div:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px -3px rgba(0, 0, 0, 0.08);
}
.results strong {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Simulador visual i circuit SVG */
#circuit {
  display: block;
  width: 100%;
  max-height: 420px;
  margin: 1.5rem auto;
  background: radial-gradient(ellipse at center, var(--tint) 0%, var(--bg) 80%);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.04);
}
#circuit text {
  fill: var(--text);
  font: 600 13px system-ui, sans-serif;
  user-select: none;
}
.riba {
  fill: none;
  stroke: var(--line);
  stroke-width: 3;
  stroke-dasharray: 8 6;
}
.balisa {
  fill: var(--surface);
  stroke: var(--primary);
  stroke-width: 3;
  transition: fill 0.15s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.15s ease, filter 0.2s ease, r 0.15s ease;
}
.balisa.activa {
  fill: #fde047;
  stroke: #ca8a04;
  stroke-width: 4;
  r: 12;
  filter: drop-shadow(0 0 8px #facc15) drop-shadow(0 0 16px #eab308);
}
@media (prefers-color-scheme: dark) {
  .balisa.activa {
    fill: #fef08a;
    stroke: #facc15;
    stroke-width: 4;
    filter: drop-shadow(0 0 10px #facc15) drop-shadow(0 0 22px #ca8a04);
  }
}

/* Botons d'acció del simulador */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
}
.actions button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  transition: all 0.2s ease;
}
.actions button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}
#atura {
  background: #dc2626;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
}
#atura:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Indicador d'estat */
#estat {
  padding: 0.85rem 1.2rem;
  background: var(--tint);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  font-weight: 500;
  margin: 1rem 0;
}

/* Esquema d'arquitectura */
.architecture {
  padding: 1.5rem;
  background: var(--tint);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  line-height: 2;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.95rem;
}

/* -------------------------------------------------------------
   SISTEMA DE PESTANYES (TABS) ACCESSIBLES PER A MATERIAL I REAPROFITAMENT
   ------------------------------------------------------------- */
.tab-container {
  margin: 2rem 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.tab-list {
  display: flex;
  overflow-x: auto;
  border-bottom: 2px solid var(--line);
  background: var(--bg);
  padding: 0.5rem 0.5rem 0;
  gap: 0.25rem;
  scrollbar-width: thin;
}

.tab-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 10px 10px 0 0;
  padding: 0.75rem 1.2rem;
  font: 600 0.95rem system-ui, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  transition: all 0.2s ease;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.03);
}

@media (prefers-color-scheme: dark) {
  .tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
  }
}

.tab-btn[aria-selected="true"] {
  color: var(--primary);
  background: var(--surface);
  border-bottom: 3px solid var(--primary);
  font-weight: 700;
}

.tab-panel {
  padding: 1.75rem;
  outline: none;
  animation: tabFadeIn 0.25s ease-in-out;
}

@keyframes tabFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Targetes de materials i components */
.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.material-card {
  padding: 1.25rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.material-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.material-card h4 {
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.material-card .spec-tag {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: var(--tint);
  color: var(--primary);
  border: 1px solid var(--line);
}

.material-card ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.92rem;
  line-height: 1.6;
}

/* Badges i etiquetes per a cursos i àmbits */
.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-fpb {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.badge-eso {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}
.badge-centre {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}
@media (prefers-color-scheme: dark) {
  .badge-fpb {
    background: #78350f;
    color: #fef3c7;
    border-color: #92400e;
  }
  .badge-eso {
    background: #075985;
    color: #e0f2fe;
    border-color: #0284c7;
  }
  .badge-centre {
    background: #14532d;
    color: #dcfce7;
    border-color: #166534;
  }
}

/* Targetes de reaprofitament */
.reaprofita-item {
  padding: 1.25rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 1.25rem;
}
.reaprofita-item:last-child {
  margin-bottom: 0;
}
.reaprofita-item h4 {
  margin: 0.5rem 0 0.6rem;
  font-size: 1.15rem;
}

/* Targetes d'equips */
.equips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}
.equips-grid article {
  padding: 1.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-top: 5px solid var(--primary);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
}
.equips-grid article h3 {
  margin-top: 0;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Línia de temps dels Primers Dies */
.days {
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin: 1.5rem 0;
}
.days > li {
  position: relative;
  padding: 1.25rem 1.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 5px solid var(--primary);
  border-radius: 12px;
  transition: transform 0.15s ease;
}
.days > li:hover {
  transform: translateX(4px);
}
.days > li h3 {
  margin-top: 0;
  font-size: 1.15rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

caption {
  text-align: left;
  color: var(--muted);
  padding: 1rem 0;
  font-size: 0.95rem;
}

section {
  scroll-margin-top: 1.5rem;
}

@media print {
  .toc,
  .actions,
  .fields,
  #error,
  .tab-list {
    display: none;
  }
  .tab-panel[hidden] {
    display: block !important;
  }
  section {
    break-inside: auto;
  }
  h2,
  h3 {
    break-after: avoid;
  }
  .table-scroll {
    overflow: visible;
  }
}
