/* ══════════════════════════════════════════════════════════════════════
   Mèntor — Aula Virtual · Centre Mompó
   Estètica: "quadern d'anatomia" — paper ossi, tinta verda fosca,
   sèrif Fraunces per a títols. Sobri, càlid, editorial.
   ══════════════════════════════════════════════════════════════════════ */

/* ── Font (vendoritzada: funciona sense internet exterior) ─────────── */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/fonts/fraunces-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/fonts/fraunces-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+1E00-1E9F, U+2020, U+20A0-20AB;
}

/* ── Variables del sistema ─────────────────────────────────────────── */
:root {
  /* Paper i tinta */
  --paper:      #f7f3ec;   /* fons general: os, càlid */
  --paper-alt:  #efe9de;   /* fons secundari */
  --carta:      #fffdf8;   /* targetes */
  --tinta:      #22302a;   /* text principal: verd-negre */
  --tinta-2:    #5c6a61;   /* text secundari */
  --tinta-3:    #93a098;   /* text terciari, metadades */

  /* Accents */
  --verd:       #2e5d4e;   /* accent principal: eucaliptus fosc */
  --verd-clar:  #e3ece6;   /* fons d'accent suau */
  --terra:      #b4593a;   /* terracota: alertes, èmfasi puntual */
  --or:         #c19a3d;   /* detall daurat: números de mòdul */

  /* Línies */
  --vora:       #ddd4c3;
  --vora-forta: #22302a;

  --serif: "Fraunces", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;

  --ombra: 0 1px 2px rgba(34, 48, 42, .06), 0 8px 24px -12px rgba(34, 48, 42, .18);
  --radi: 10px;
}

/* ── Base ──────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--tinta);
  background: var(--paper);
  /* textura de paper subtil: dues trames diagonals quasi invisibles */
  background-image:
    repeating-linear-gradient(45deg, rgba(34,48,42,.012) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(-45deg, rgba(34,48,42,.012) 0 1px, transparent 1px 7px);
  min-height: 100vh;
}

/* Alpine: amaga els elements fins que estiga inicialitzat */
[x-cloak] { display: none !important; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; }

a { color: var(--verd); }

button { font: inherit; cursor: pointer; }

/* ── Capçalera comuna ──────────────────────────────────────────────── */
.capcalera {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--vora);
  background: var(--carta);
}

.marca {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--tinta);
  text-decoration: none;
  letter-spacing: -.01em;
}
.marca em { font-style: normal; color: var(--verd); }

.capcalera .subtitol {
  font-size: .78rem;
  color: var(--tinta-3);
  text-transform: uppercase;
  letter-spacing: .14em;
}

.capcalera .espai { flex: 1; }

.capcalera .usuari { font-size: .9rem; color: var(--tinta-2); }

.enllac-discret {
  background: none;
  border: none;
  color: var(--tinta-3);
  font-size: .85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.enllac-discret:hover { color: var(--terra); }

/* ── Contenidor ────────────────────────────────────────────────────── */
.contenidor {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) 4rem;
}

.titol-pagina {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  margin-bottom: .3rem;
}

.sota-titol { color: var(--tinta-2); margin-bottom: 2.2rem; max-width: 60ch; }

/* Etiqueta petita en versaletes: "ELS TEUS CURSOS", "MÒDUL 3"... */
.etiqueta {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--or);
  margin-bottom: .6rem;
}

/* ── Pàgina de login ───────────────────────────────────────────────── */
.pagina-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.caixa-login {
  width: 100%;
  max-width: 400px;
  background: var(--carta);
  border: 1px solid var(--vora);
  border-top: 3px solid var(--verd);
  border-radius: var(--radi);
  box-shadow: var(--ombra);
  padding: 2.5rem 2.2rem 2.2rem;
  animation: apareix .5s ease both;
}

@keyframes apareix {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.caixa-login .marca { font-size: 1.9rem; display: block; }
.caixa-login .subtitol {
  font-size: .75rem;
  color: var(--tinta-3);
  text-transform: uppercase;
  letter-spacing: .18em;
  margin: .4rem 0 2rem;
}

.camp { margin-bottom: 1.1rem; }

.camp label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--tinta-2);
  margin-bottom: .35rem;
}

.camp input {
  width: 100%;
  font: inherit;
  padding: .65rem .8rem;
  border: 1px solid var(--vora);
  border-radius: 6px;
  background: var(--paper);
  color: var(--tinta);
  transition: border-color .15s, box-shadow .15s;
}
.camp input:focus {
  outline: none;
  border-color: var(--verd);
  box-shadow: 0 0 0 3px var(--verd-clar);
}

/* ── Botons ────────────────────────────────────────────────────────── */
.boto {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .65rem 1.4rem;
  border: 1px solid var(--verd);
  border-radius: 6px;
  background: var(--verd);
  color: #fff;
  font-weight: 600;
  font-size: .95rem;
  transition: background .15s, transform .1s;
}
.boto:hover { background: #234a3e; }
.boto:active { transform: translateY(1px); }
.boto:disabled { opacity: .55; cursor: default; }

.boto-ample { width: 100%; }

.boto-secundari {
  background: transparent;
  color: var(--verd);
}
.boto-secundari:hover { background: var(--verd-clar); }

/* ── Missatges ─────────────────────────────────────────────────────── */
.avis {
  padding: .7rem 1rem;
  border-radius: 6px;
  font-size: .9rem;
  margin-bottom: 1.1rem;
  border: 1px solid;
}
.avis-error { background: #f9ece7; border-color: #e4c3b5; color: var(--terra); }
.avis-ok    { background: var(--verd-clar); border-color: #c4d8cc; color: var(--verd); }

/* ── Targetes de curs ──────────────────────────────────────────────── */
.reixa-cursos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.4rem;
}

.targeta-curs {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--carta);
  border: 1px solid var(--vora);
  border-radius: var(--radi);
  padding: 1.6rem 1.5rem 1.4rem;
  box-shadow: var(--ombra);
  transition: transform .18s ease, border-color .18s;
  animation: apareix .5s ease both;
}
.targeta-curs:nth-child(2) { animation-delay: .07s; }
.targeta-curs:nth-child(3) { animation-delay: .14s; }
.targeta-curs:nth-child(4) { animation-delay: .21s; }
.targeta-curs:hover { transform: translateY(-3px); border-color: var(--verd); }

.targeta-curs h2 { font-size: 1.3rem; margin: .2rem 0 .5rem; }

.targeta-curs p {
  font-size: .88rem;
  color: var(--tinta-2);
  margin-bottom: 1.2rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Barra de progrés */
.progres {
  display: flex;
  align-items: center;
  gap: .7rem;
  font-size: .78rem;
  color: var(--tinta-3);
}
.progres-barra {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--paper-alt);
  overflow: hidden;
}
.progres-barra > div {
  height: 100%;
  border-radius: 3px;
  background: var(--verd);
  transition: width .4s ease;
}

/* ── Vista de curs: mòduls + contingut ─────────────────────────────── */
.disposicio-curs {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 2.2rem;
  align-items: start;
}
@media (max-width: 800px) {
  .disposicio-curs { grid-template-columns: 1fr; }
}

.llista-moduls {
  background: var(--carta);
  border: 1px solid var(--vora);
  border-radius: var(--radi);
  overflow: hidden;
  position: sticky;
  top: 1.2rem;
}
@media (max-width: 800px) { .llista-moduls { position: static; } }

/* Capçalera de tema dins de l'índex */
.llista-moduls .tema + .tema { border-top: 1px solid var(--vora); }
.llista-moduls .tema-titol {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .8rem 1rem .5rem;
  font-family: var(--serif);
  font-weight: 600;
  font-size: .98rem;
  background: var(--paper-alt);
  border-bottom: 1px solid var(--vora);
}

.llista-moduls ul { list-style: none; }
.llista-moduls li + li { border-top: 1px dashed var(--vora); }

.llista-moduls button {
  display: flex;
  align-items: center;
  gap: .8rem;
  width: 100%;
  text-align: left;
  padding: .85rem 1rem;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: var(--tinta);
  font-size: .92rem;
  transition: background .12s;
}
.llista-moduls button:hover:not(:disabled) { background: var(--paper); }
.llista-moduls li.actiu button {
  border-left-color: var(--verd);
  background: var(--verd-clar);
  font-weight: 600;
}
.llista-moduls button:disabled { color: var(--tinta-3); cursor: not-allowed; }

/* Les lliçons van lleugerament indentades sota el seu tema */
.llista-moduls li button { padding-left: 1.6rem; font-size: .9rem; }

/* Número de mòdul en sèrif daurat */
.num-modul {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--or);
  min-width: 1.4rem;
  text-align: center;
}
.llista-moduls button:disabled .num-modul { color: var(--tinta-3); }

.marca-estat { margin-left: auto; font-size: .85rem; }
.marca-estat.fet { color: var(--verd); }
.marca-estat.bloquejat { color: var(--tinta-3); }

/* ── Contingut del mòdul ───────────────────────────────────────────── */
.contingut-modul {
  background: var(--carta);
  border: 1px solid var(--vora);
  border-radius: var(--radi);
  box-shadow: var(--ombra);
  padding: clamp(1.4rem, 3vw, 2.4rem);
  animation: apareix .35s ease both;
}

.contingut-modul h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 1.4rem; }

/* Iframe de Vimeo responsiu 16:9 */
.marc-video {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--tinta);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.8rem;
}
.marc-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Text del mòdul (HTML generat del Markdown) */
.prosa { max-width: 68ch; }
.prosa h1, .prosa h2, .prosa h3 { margin: 1.6em 0 .5em; }
.prosa h1:first-child { margin-top: 0; }
.prosa h1 { font-size: 1.55rem; }
.prosa h2 { font-size: 1.2rem; }
.prosa h3 { font-size: 1.05rem; }
.prosa p, .prosa ul, .prosa ol { margin-bottom: 1em; }
.prosa ul, .prosa ol { padding-left: 1.4rem; }
.prosa li { margin-bottom: .3em; }
.prosa blockquote {
  border-left: 3px solid var(--or);
  padding: .2rem 0 .2rem 1.1rem;
  margin: 1.4em 0;
  font-family: var(--serif);
  font-size: 1.08rem;
  color: var(--tinta-2);
}
.prosa table {
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: .92rem;
  width: 100%;
}
.prosa th, .prosa td {
  border: 1px solid var(--vora);
  padding: .45rem .8rem;
  text-align: left;
}
.prosa th { background: var(--paper-alt); font-weight: 600; }
.prosa code {
  background: var(--paper-alt);
  padding: .1em .35em;
  border-radius: 4px;
  font-size: .9em;
}
.prosa img { max-width: 100%; border-radius: 6px; }

/* Peu del mòdul: PDF + completar */
.peu-modul {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem;
  align-items: center;
  margin-top: 2.2rem;
  padding-top: 1.6rem;
  border-top: 1px dashed var(--vora);
}
.peu-modul .espai { flex: 1; }

.modul-completat {
  color: var(--verd);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}

/* ── Tests dels mòduls ─────────────────────────────────────────────── */
.bloc-test {
  margin-top: 2.2rem;
  padding-top: 1.6rem;
  border-top: 1px dashed var(--vora);
}

/* Convit a fer el test */
.convit-test {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  background: var(--verd-clar);
  border: 1px solid #c4d8cc;
  border-radius: var(--radi);
  padding: 1.1rem 1.3rem;
}
.convit-test .info-test { margin: 0; }

.titol-test { font-size: 1.35rem; margin-bottom: .3rem; }

.info-test { font-size: .88rem; color: var(--tinta-2); margin-bottom: 1.4rem; }

/* Pregunta del test */
.pregunta {
  border: 1px solid var(--vora);
  border-left: 3px solid var(--vora);
  border-radius: 8px;
  padding: 1rem 1.2rem 1.1rem;
  margin-bottom: 1.1rem;
  background: var(--paper);
}
.pregunta legend {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  font-weight: 600;
  padding: 0 .4rem;
  background: var(--paper);
}
.pregunta .marca-estat.mal { color: var(--terra); }

/* Estats després de la correcció */
.pregunta.encertada { border-left-color: var(--verd); }
.pregunta.fallada   { border-left-color: var(--terra); }

.opcio {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .4rem .3rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .95rem;
}
.opcio:hover { background: var(--paper-alt); }
.opcio input { accent-color: var(--verd); }
.opcio input:disabled + span { color: var(--tinta-2); }

.peu-test { display: flex; gap: .8rem; margin-top: 1.4rem; }

/* ── Taula d'administració ─────────────────────────────────────────── */
.embolcall-taula { overflow-x: auto; }

.taula-admin {
  width: 100%;
  border-collapse: collapse;
  background: var(--carta);
  border: 1px solid var(--vora);
  border-radius: var(--radi);
  font-size: .9rem;
}
.taula-admin th, .taula-admin td {
  padding: .65rem .9rem;
  border-bottom: 1px solid var(--vora);
  text-align: left;
  white-space: nowrap;
}
.taula-admin thead th {
  background: var(--paper-alt);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--tinta-2);
}
.taula-admin td.centrat, .taula-admin th.centrat { text-align: center; }
.taula-admin .fet { color: var(--verd); font-weight: 700; }
.taula-admin .pendent { color: var(--vora); }
.taula-admin .nota-test { display: block; color: var(--or); font-weight: 600; }

.selector-curs {
  font: inherit;
  padding: .55rem .8rem;
  border: 1px solid var(--vora);
  border-radius: 6px;
  background: var(--carta);
  color: var(--tinta);
  margin-bottom: 1.6rem;
  min-width: min(100%, 340px);
}

/* ── Mi espacio (expedient de l'alumne) ────────────────────────────── */
.seccio-espai { margin-bottom: 2.6rem; }

.targeta-espai {
  background: var(--carta);
  border: 1px solid var(--vora);
  border-radius: var(--radi);
  padding: 1.4rem 1.5rem 1.3rem;
  box-shadow: var(--ombra);
  margin-bottom: 1.2rem;
}
.targeta-espai h2 { font-size: 1.15rem; margin-bottom: .3rem; }
.targeta-espai .progres { margin: .6rem 0 .9rem; }

.grup-espai { color: var(--tinta-3); font-weight: 400; font-size: .95rem; }

.horari-espai { font-size: .9rem; color: var(--tinta-2); margin-bottom: .7rem; }

.nota-buida { font-size: .88rem; color: var(--tinta-3); font-style: italic; }

.dies-espai { display: flex; flex-wrap: wrap; gap: .4rem; }

.xip {
  display: inline-block;
  padding: .1rem .6rem;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.xip-ok      { background: var(--verd-clar); border-color: #c4d8cc; color: var(--verd); }
.xip-pendent { background: var(--paper-alt); border-color: var(--vora); color: var(--tinta-2); }
.xip-vencuda { background: #f9ece7; border-color: #e4c3b5; color: var(--terra); }

.formulari-password { max-width: 420px; }
.formulari-password .camp { margin-bottom: 1rem; }

/* ── Utilitats ─────────────────────────────────────────────────────── */
.carregant { color: var(--tinta-3); font-style: italic; padding: 2rem 0; }

/* Accessibilitat: sense animacions si l'usuari ho demana al sistema */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
