@import url('tokens.css');
/* Fonts carregades via <link> al HTML per evitar duplicats */

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

html { height: 100%; }

body {
  background: linear-gradient(135deg, var(--bg-gradient-1), var(--bg-gradient-2));
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh; /* fallback */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-color-dark); }

/* ─── WRAPPER ─── */
#main-menu {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 2rem 2.5rem 3rem;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  flex-grow: 1;
}

/* ─── HEADER ─── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 2.5rem;
  width: 100%;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.ideorum-mark {
  display: flex;
  align-items: center;
  height: 60px;
  flex-shrink: 0;
  text-decoration: none;
  transition: opacity 0.2s ease;
}
.ideorum-mark:hover { opacity: 0.75; }
.ideorum-mark img { height: 100%; width: auto; display: block; max-width: none; }
.brand-text { display: flex; flex-direction: column; gap: 0.15rem; align-items: center; text-align: center; }
@media (max-width: 900px) {
  .ideorum-mark { height: 48px; }
}
@media (max-width: 600px) {
  .ideorum-mark { height: 38px; }
}

header h1 {
  font-family: var(--title-font);
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  color: var(--brand-sage);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
}

.header-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.ach-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--number-font, var(--font-main));
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--brand-orange, #FBA633);
  background: rgba(250, 166, 51, 0.1);
  border: 1px solid rgba(250, 166, 51, 0.3);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  cursor: default;
  user-select: none;
}

.header-credit {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.6;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.header-credit:hover {
  opacity: 1;
  color: var(--accent-color);
}

/* ─── GRID ─── */
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: clamp(0.9rem, 2vw, 1.5rem);
  width: 100%;
  align-content: start;
}

/* ─── CARD ─── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  padding: clamp(1.1rem, 3vw, 1.6rem) clamp(1.1rem, 3vw, 1.6rem) clamp(1rem, 2.5vw, 1.4rem);
  cursor: pointer;
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
  position: relative;
  text-decoration: none;
  color: var(--text-primary);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(31, 41, 55, 0.04);
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-color);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(29, 174, 159, 0.5);
  box-shadow: 0 12px 28px rgba(31, 41, 55, 0.10), 0 0 0 1px var(--accent-glow);
}

.card:hover::before {
  opacity: 1;
}

/* ─── CARD LEVEL BADGE ─── */
.card-level {
  position: absolute;
  top: 0;
  right: 0;
  background: rgba(29, 174, 159, 0.12);
  color: var(--accent-color);
  font-size: 0.65rem;
  padding: 0.35rem 0.85rem;
  font-weight: 700;
  border-bottom-left-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  border-left: 1px solid rgba(29, 174, 159, 0.2);
  border-bottom: 1px solid rgba(29, 174, 159, 0.2);
}

/* ─── CARD CONTENT ─── */
.card h2 {
  font-size: 1.15rem;
  margin-bottom: 0.6rem;
  color: var(--text-primary);
  line-height: 1.3;
  font-weight: 600;
  padding-right: 4rem;
  transition: color 0.2s ease;
}

.card:hover h2 {
  color: var(--accent-color);
}

.card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  flex-grow: 1;
  line-height: 1.55;
  margin-bottom: 1.4rem;
  font-weight: 300;
}

/* ─── PLAY BUTTON ─── */
.play-btn {
  background: transparent;
  color: var(--accent-color);
  border: 1px solid rgba(29, 174, 159, 0.35);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  transition: all 0.2s ease;
  margin-top: auto;
}

.card:hover .play-btn {
  background: var(--accent-color);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--accent-glow);
  border-color: var(--accent-color);
}

/* ─── RESPONSIVE ─── */
@media (max-width: 1280px) {
  #main-menu { padding: 1.5rem 2rem 2.5rem; }
  .grid-container { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

@media (max-width: 900px) {
  #main-menu { padding: 1.2rem 1.5rem 2rem; }
  .grid-container { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.2rem; }
  header { margin-bottom: 1.8rem; }
  .header-sub { display: none; }
}

@media (max-width: 600px) {
  #main-menu { padding: 1rem 1rem 2rem; }
  .grid-container { grid-template-columns: 1fr; gap: 1rem; }
  header { margin-bottom: 1.4rem; }
  header h1 { font-size: 1.5rem; }
}

/* Pantalles baixes d'aula */
@media (max-height: 800px) and (min-width: 601px) {
  #main-menu { padding: 1rem 2rem 1.5rem; }
  header { margin-bottom: 1.5rem; padding: 0.9rem 0; }
  .grid-container { gap: 1.1rem; }
}

/* ═══════════════════════════════════════════════
   ACCESSIBILITAT (a11y) — Portal
═══════════════════════════════════════════════ */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.skip-link {
  position: absolute;
  top: -40px;
  left: 8px;
  background: var(--accent-color, #1DAE9F);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
  z-index: 10000;
  font-family: var(--font-main);
}
.skip-link:focus {
  top: 8px;
  outline: 3px solid var(--brand-orange);
  outline-offset: 2px;
}
.card:focus-visible {
  outline: 3px solid var(--brand-orange) !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 0 6px rgba(232, 146, 61, 0.30);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* CSV export button al header */
.csv-export-btn {
  background: rgba(29,174,159,0.10);
  border: 1px solid rgba(29,174,159,0.4);
  color: var(--accent-color-dark);
  padding: 6px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.csv-export-btn:hover {
  background: var(--accent-color);
  color: #ffffff;
  border-color: var(--accent-color);
}

/* ═══════════════════════════════════════════════
   FOOTER GLOBAL (compartit a totes les pàgines)
   Estil ideorum.cat: footer fosc sobre lloc clar
═══════════════════════════════════════════════ */
.site-footer {
  padding: 1.5rem 1.5rem 1.75rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.75);
  font-size: .85rem;
  background: var(--footer-bg);
  margin-top: auto;
}
.site-footer a { color: rgba(255, 255, 255, 0.85); text-decoration: none; }
.site-footer a:hover, .site-footer a:focus { color: var(--accent-color); text-decoration: underline; }
.site-footer .footer-links { margin-bottom: .5rem; }
.site-footer .footer-links a { margin: 0 .5rem; }
.site-footer .license-line { font-size: .8rem; opacity: .85; }
@media (max-width: 480px) {
  .site-footer { padding: 1rem .75rem; font-size: .78rem; }
  .site-footer .footer-links a { display: inline-block; margin: .15rem .35rem; }
}

/* ═══════════════════════════════════════════════
   MODE FOSC · portal
═══════════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
  .card { background: #1e293b; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
  .card:hover { box-shadow: 0 12px 28px rgba(0,0,0,0.5), 0 0 0 1px var(--accent-glow); }
  .card-level { background: rgba(94,234,212,0.15); color: #5eead4; }
  .play-btn { color: var(--accent-color); border-color: rgba(94,234,212,0.35); }
  .csv-export-btn { background: rgba(94,234,212,0.10); border-color: rgba(94,234,212,0.4); color: var(--accent-color); }
  .ach-counter { background: rgba(232,146,61,0.15); border-color: rgba(232,146,61,0.40); }
}
