/* ==========================================================================
   Mise en page : barre d'onglets (mobile), menu latéral (ordinateur),
   carte « Reprendre », filtres et tuiles de thèmes
   ========================================================================== */

:root {
  --nav-w: 15.5rem;
  --tabbar-h: 4.25rem;
  --radius-xl: 18px;
}

.icon { width: 1.25rem; height: 1.25rem; }

/* ───────────── Pastille d'icône de thème ───────────── */

.theme-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.75rem; height: 2.75rem;
  border-radius: 12px;
  background: color-mix(in srgb, var(--c, var(--accent)) 18%, transparent);
  color: var(--c, var(--accent));
}
.theme-icon .icon { width: 1.4rem; height: 1.4rem; }
.theme-icon.small { width: 2.1rem; height: 2.1rem; border-radius: 9px; }
.theme-icon.small .icon { width: 1.1rem; height: 1.1rem; }

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.25rem; height: 2.25rem;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), #FFB066);
  color: #2A1200;
  font-weight: 700;
}
.avatar.large { width: 3.25rem; height: 3.25rem; font-size: 1.3rem; }

/* ───────────── Menu latéral (ordinateur) ───────────── */

.app-nav {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  gap: 1.5rem;
  width: var(--nav-w);
  padding: 1.5rem 1rem 1.25rem;
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 0 .4rem;
  color: var(--text);
  text-decoration: none;
}
.brand-name { font-weight: 700; font-size: 1.1rem; }
.brand-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.25rem; height: 2.25rem;
  padding-bottom: .2rem;
  border-radius: 10px;
  background: #0F1E33;
  color: #fff;
  font: 700 1.1rem/1 var(--font-display);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: .28rem;
  background: var(--accent);
}
.brand-mark.large { width: 3.25rem; height: 3.25rem; font-size: 1.55rem; border-radius: 14px; }

.nav-list { display: grid; gap: .2rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: .6rem .7rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .95rem;
  text-align: left;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.is-current { background: var(--surface); color: var(--text); }
.nav-item kbd { margin-left: auto; font-size: .7rem; }

.btn-block { width: 100%; }

.nav-profile {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin-top: auto;
  padding: .6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
}
.nav-profile:hover { border-color: var(--line-strong); }
.nav-profile-text { display: grid; min-width: 0; line-height: 1.25; font-weight: 600; }
.nav-profile-text > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-profile-sub { font-size: .78rem; font-weight: 500; color: var(--text-muted); }

/* ───────────── Barre d'onglets (mobile) ───────────── */

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 .25rem env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg-deep) 90%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  height: calc(var(--tabbar-h) - .5rem);
  margin-bottom: .25rem;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: .7rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 14px;
  -webkit-tap-highlight-color: transparent;
}
.tab .icon { width: 1.35rem; height: 1.35rem; }
.tab.is-current { color: var(--text); }
.tab-main { justify-content: flex-end; padding-bottom: .55rem; color: var(--text); }
.tab-main-circle {
  display: grid;
  place-items: center;
  width: 3.2rem; height: 3.2rem;
  margin-top: -1.35rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 40%, transparent), 0 0 0 5px var(--bg);
}
.tab-main-circle .icon { width: 1.45rem; height: 1.45rem; }
.tab:active .icon, .tab-main:active .tab-main-circle { transform: scale(.92); }

/* ───────────── Contenu ───────────── */

.home {
  padding: 1.25rem 1rem calc(var(--tabbar-h) + 2rem + env(safe-area-inset-bottom));
}
.home > * { max-width: 68rem; }

.hello {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.hello-date { font-size: .85rem; color: var(--text-muted); font-weight: 500; }
.greeting { font-size: 1.75rem; font-weight: 700; letter-spacing: -.015em; line-height: 1.15; }
.avatar-btn { padding: 0; border: 0; background: none; border-radius: 50%; }

/* Carte « Reprendre » */
.resume {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1rem 1.1rem;
  margin-bottom: 2rem;
  padding: 1.25rem;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: var(--radius-xl);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 60%),
    var(--surface);
}
.resume:empty { display: none; }
.resume[data-state="empty"] { grid-template-columns: 1fr; }
.resume-kicker {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--accent);
}
.resume-kicker .icon { width: 1rem; height: 1rem; }
.resume-title { margin-top: .2rem; font-size: 1.3rem; font-weight: 700; line-height: 1.25; }
.resume-note { margin-top: .25rem; color: var(--text-muted); font-size: .92rem; }
.resume-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .6rem; }
.resume-actions .btn { flex: 1 1 10rem; }
.resume-actions .icon { width: 1.1rem; height: 1.1rem; }

.resume-score {
  --size: 5rem;
  position: relative;
  display: grid;
  place-items: center;
  grid-template-rows: auto auto;
  align-content: center;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--surface) 80%, transparent 81%),
    conic-gradient(var(--tone) calc(var(--value) * 1%), var(--line) 0);
}
.resume[data-tone="high"] { --tone: var(--done); }
.resume[data-tone="mid"] { --tone: var(--verif); }
.resume[data-tone="low"] { --tone: var(--danger); }
.resume-score-value { font: 700 1.6rem/1 var(--font-display); color: var(--tone); }
.resume-score-max { font-size: .72rem; color: var(--text-muted); font-weight: 600; }

/* En-tête de section et filtres */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}
.section-title { font-size: 1.2rem; font-weight: 700; }
.section-sub { font-size: .85rem; color: var(--text-muted); }

.chips {
  display: flex;
  gap: .5rem;
  margin: 0 -1rem 1rem;
  padding: 0 1rem .25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 2.3rem;
  padding: .35rem .95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: .9rem;
}
.chip span { color: var(--text-muted); font-weight: 500; }
.chip[aria-selected="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip[aria-selected="true"] span { color: color-mix(in srgb, var(--bg) 65%, var(--text)); }

/* Tuiles */
[data-status="done"] { --status: var(--done); }
[data-status="verif"] { --status: var(--verif); }
[data-status="wait"] { --status: var(--wait); }

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}

.tile-theme {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 12.5rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(90% 70% at 100% 0%, color-mix(in srgb, var(--c) 16%, transparent), transparent 70%),
    var(--surface);
  color: var(--text);
  text-align: left;
  overflow: hidden;
  transition: transform .15s var(--ease), border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.tile-theme:active { transform: scale(.98); }
@media (hover: hover) {
  .tile-theme:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 55%, var(--line)); }
}

.tile-status {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .7rem;
  font-weight: 600;
  color: var(--status);
}
.tile-status::before { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; }
.tile-theme .tile-status { position: absolute; top: 1.05rem; right: 1rem; }
[data-theme="light"] .tile-status[data-status="verif"] { color: #7A5E00; }

.tile-code {
  margin-top: .9rem;
  font: 700 1.55rem/1.05 var(--font-display);
  letter-spacing: .01em;
}
.tile-name {
  margin-top: .15rem;
  font-size: .88rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-detail { margin-top: .35rem; font-size: .76rem; color: var(--text-muted); opacity: .85; }

.tile-progress { display: grid; gap: .35rem; width: 100%; margin-top: auto; padding-top: .9rem; }
.tile-bar { display: block; height: .35rem; border-radius: 999px; background: var(--line); overflow: hidden; }
.tile-bar span { display: block; height: 100%; border-radius: inherit; background: var(--c); }
.tile-progress-text { font-size: .76rem; color: var(--text-muted); }
.tile-progress-text strong { color: var(--text); font-weight: 700; }

/* En préparation */
.upcoming {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}
.upcoming summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .9rem 1rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .92rem;
  list-style: none;
  cursor: pointer;
}
.upcoming summary::-webkit-details-marker { display: none; }
.upcoming-chevron { transition: transform .2s var(--ease); }
.upcoming[open] .upcoming-chevron { transform: rotate(180deg); }
.upcoming-list { list-style: none; border-top: 1px solid var(--line); }
.upcoming-list li {
  display: grid;
  grid-template-columns: 3.75rem 1fr auto;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  font-size: .9rem;
  color: var(--text-muted);
}
.upcoming-list li + li { border-top: 1px solid var(--line); }
.upcoming-code { font: 600 1rem/1 var(--font-display); letter-spacing: .02em; }
.upcoming-cat { font-size: .8rem; opacity: .8; }

.site-footer {
  margin-top: 2.5rem;
  font-size: .8rem;
  color: var(--text-muted);
  opacity: .8;
}

/* ───────────── Écrans moyens ───────────── */

@media (min-width: 600px) {
  .home { padding-inline: 1.75rem; }
  .chips { margin-inline: 0; padding-inline: 0; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 1rem; }
  .resume { grid-template-columns: auto 1fr auto; padding: 1.5rem; }
  .resume[data-state="empty"] { grid-template-columns: 1fr auto; }
  .resume-actions { grid-column: auto; flex-direction: column; }
  .resume-actions .btn { flex: none; }
  .upcoming-list li { grid-template-columns: 4.5rem 1fr auto; }
}

/* ───────────── Ordinateur : menu latéral ───────────── */

@media (min-width: 1000px) {
  .app-nav { display: flex; }
  .tabbar, .avatar-btn { display: none; }
  .home { margin-left: var(--nav-w); padding: 2.5rem 3rem 3rem; }
  .greeting { font-size: 2rem; }
  .resume { margin-bottom: 2.5rem; }
}

@media (max-width: 380px) {
  .tile-theme { min-height: 11.5rem; padding: .85rem; }
  .tile-code { font-size: 1.35rem; }
}

/* ───────────── Raccourcis « Réviser » ───────────── */

.hub { margin-bottom: 2rem; }
.hub-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}
.hub-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .35rem;
  min-height: 8.5rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(90% 80% at 100% 0%, color-mix(in srgb, var(--c) 14%, transparent), transparent 70%),
    var(--surface);
  color: var(--text);
  text-align: left;
  transition: transform .15s var(--ease), border-color .15s;
}
.hub-card .theme-icon { width: 2.4rem; height: 2.4rem; margin-bottom: .35rem; }
.hub-card .theme-icon .icon { width: 1.2rem; height: 1.2rem; }
.hub-title { font-weight: 700; }
.hub-text { font-size: .82rem; color: var(--text-muted); line-height: 1.35; }
.hub-text strong { color: var(--c); font: 700 1.05rem/1 var(--font-display); }
.hub-card:active:not(:disabled) { transform: scale(.98); }
.hub-card:disabled { opacity: .55; cursor: default; }
@media (hover: hover) {
  .hub-card:hover:not(:disabled) { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 55%, var(--line)); }
}
@media (min-width: 760px) {
  .hub-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
}

.nav-badge {
  margin-left: auto;
  min-width: 1.4rem;
  padding: .05rem .4rem;
  border-radius: 999px;
  background: #38BDF8;
  color: #06223A;
  font-size: .72rem;
  font-weight: 700;
  text-align: center;
}

/* Logo de la section (écusson rond) : contour discret sur fond sombre pour détacher le disque bleu */
.brand-logo {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .14), 0 4px 12px rgba(5, 12, 24, .35);
}
[data-theme="light"] .brand-logo { box-shadow: 0 3px 10px rgba(15, 30, 51, .22); }
.brand-logo.large { width: 4rem; height: 4rem; }
