/* ============================================================
   POLICES — Inter (sans-serif) + JetBrains Mono (monospace)
   ============================================================ */

:root {
  --font-sans: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo,
    Consolas, "Liberation Mono", monospace;
}

html,
body {
  font-family: var(--font-sans);
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

code,
pre,
kbd,
samp,
.font-mono,
.size-h6 {
  font-family: var(--font-mono);
  letter-spacing: 0;
}

/* Titres de widgets un poil plus serrés */
.widget-header,
.size-h2,
.size-h3,
h1, h2, h3 {
  letter-spacing: -0.02em;
  font-weight: 600;
}

/* ============================================================
   THÈME — noir profond avec widgets décollés
   ============================================================ */

/* Widgets : translucides pour laisser deviner le wallpaper en arrière-plan,
   compensé par un backdrop-filter blur plus prononcé pour garder la lisibilité.
   - background alpha 0.62 = bonne lisibilité texte clair sur wallpaper sombre
   - blur(14px) + saturate(140%) = effet "verre fumé" propre */
html[data-scheme="dark"] .widget-content-frame,
html[data-scheme="dark"] .widget,
html[data-scheme="dark"] .widget-content {
  background-color: rgba(19, 19, 24, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}

/* La barre de navigation reste plus opaque pour rester lisible quel que soit
   le wallpaper qui défile derrière. */
html[data-scheme="dark"] .header-container {
  background-color: rgba(12, 12, 14, 0.78);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* ============================================================
   BACKGROUND DYNAMIQUE (Wallhaven anime+nature, voir wallpaper.js)
   ============================================================ */

/* Couche image : fixed, blur léger, légèrement agrandie pour masquer
   les bords flous générés par le filter:blur. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--bg-image, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(1px);
  z-index: -2;
  opacity: 0;
  transition: opacity 700ms ease;
  pointer-events: none;
}

/* Couche overlay sombre : par-dessus l'image, donne le contraste
   nécessaire pour que le contenu reste lisible. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.7) 100%
  );
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 700ms ease;
}

body.bg-loaded::before,
body.bg-loaded::after {
  opacity: 1;
}

/* Liens un peu plus accrocheurs sur fond noir */
html[data-scheme="dark"] a {
  text-decoration-color: rgba(255, 255, 255, 0.15);
  text-underline-offset: 0.2em;
}

html[data-scheme="dark"] a:hover {
  text-decoration-color: currentColor;
}

/* Scrollbars discrètes (Firefox + Webkit) */
html[data-scheme="dark"] {
  scrollbar-color: #2a2a2a #000;
  scrollbar-width: thin;
}
html[data-scheme="dark"] ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
html[data-scheme="dark"] ::-webkit-scrollbar-track {
  background: #000;
}
html[data-scheme="dark"] ::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 999px;
}
html[data-scheme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #3a3a3a;
}

/* Sélection de texte plus contrastée sur AMOLED */
html[data-scheme="dark"] ::selection {
  background: rgba(99, 169, 255, 0.35);
  color: #fff;
}

/* ============================================================
   FLUX RSS — affichage complet des titres
   Glance tronque par défaut à 3 lignes (`.text-truncate-3-lines`).
   On laisse le titre prendre toute la place dont il a besoin pour
   pouvoir lire l'article au complet sans hover.
   ============================================================ */

.cards-horizontal .card .text-truncate-3-lines {
  -webkit-line-clamp: unset;
  line-clamp: unset;
  display: block;
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
  line-height: 1.35;
}

/* La card horizontale s'adapte naturellement à la hauteur du titre
   le plus long de la rangée. On garde un minimum confortable. */
.cards-horizontal .card {
  min-height: calc(var(--rss-thumbnail-height, 10rem) + 9.5rem);
  height: auto;
}

/* ============================================================
   ACTU RSS (section-rss-tech) — cartes plus lisibles & premium,
   sans sortir du thème (accent primary ~217 95% 72%).
   ============================================================ */

html[data-scheme="dark"] .widget.section-rss-tech .cards-horizontal {
  scroll-snap-type: x proximity;
  gap: calc(var(--widget-content-vertical-padding) * 0.85);
  padding-bottom: 1.2rem;
}

html[data-scheme="dark"] .widget.section-rss-tech .cards-horizontal .card {
  scroll-snap-align: start;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: linear-gradient(
    168deg,
    rgba(255, 255, 255, 0.07) 0%,
    rgba(255, 255, 255, 0.025) 45%,
    rgba(0, 0, 0, 0.14) 100%
  );
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.24);
  overflow: hidden;
  transition:
    transform 0.2s ease,
    box-shadow 0.25s ease,
    border-color 0.2s ease;
}

html[data-scheme="dark"] .widget.section-rss-tech .cards-horizontal .card:hover {
  transform: translateY(-4px);
  border-color: rgba(217, 95, 72, 0.42);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.38),
    0 0 0 1px rgba(217, 95, 72, 0.14),
    0 0 28px -10px rgba(217, 95, 72, 0.22);
}

html[data-scheme="dark"] .widget.section-rss-tech .rss-card-image.thumbnail {
  transition: transform 0.35s ease;
}

html[data-scheme="dark"] .widget.section-rss-tech .card:hover .rss-card-image.thumbnail {
  transform: scale(1.045);
}

/* Flux sans image : fond type « hero » discret au lieu du SVG nu */
html[data-scheme="dark"] .widget.section-rss-tech svg.rss-card-image {
  background:
    radial-gradient(ellipse 85% 75% at 50% 32%, rgba(217, 95, 72, 0.18), transparent 58%),
    linear-gradient(185deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.2));
  box-sizing: border-box;
  padding: 1.4rem;
}

html[data-scheme="dark"] .widget.section-rss-tech .cards-horizontal .card > .flex a.color-primary-if-not-visited {
  font-weight: 500;
  font-size: 1.32rem;
  line-height: 1.38;
  letter-spacing: -0.018em;
}

html[data-scheme="dark"] .widget.section-rss-tech .list-horizontal-text {
  flex-wrap: wrap;
  row-gap: 0.35rem;
  margin-top: 0.7rem !important;
}

html[data-scheme="dark"] .widget.section-rss-tech .list-horizontal-text > li.shrink-0 {
  font-weight: 500;
  font-size: 1.05rem;
  padding: 0.22rem 0.55rem;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-text-base);
}

html[data-scheme="dark"] .widget.section-rss-tech .list-horizontal-text > li.min-width-0 {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.22rem 0.55rem;
  border-radius: 7px;
  background: rgba(217, 95, 72, 0.14);
  border: 1px solid rgba(217, 95, 72, 0.28);
  color: hsl(217, 42%, 88%);
  max-width: 100%;
}

html[data-scheme="dark"] .widget.section-rss-tech > .widget-header {
  position: relative;
  padding-bottom: 0.75rem;
  margin-bottom: 0.45rem;
}

html[data-scheme="dark"] .widget.section-rss-tech > .widget-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    hsl(217, 85%, 58%) 0%,
    rgba(217, 95, 72, 0.4) 42%,
    transparent 88%
  );
  opacity: 0.9;
}

/* ============================================================
   WIDGET SEERR — liste type Homarr avec jaquettes TMDB
   Une ligne par demande : poster | titre/meta | statut | demandeur
   ============================================================ */

.seerr-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.seerr-list > li { padding: 0; }

/* Mode "petit bloc avec ascenseur" : on borne la hauteur et on laisse le
   défilement vertical interne. La scrollbar reprend le style discret du thème
   (cf. règles `::-webkit-scrollbar` plus haut). */
.seerr-list-scroll {
  max-height: 32rem;
  overflow-y: auto;
  padding-right: 0.4rem;
  scrollbar-gutter: stable;
}

.seerr-row {
  display: grid;
  grid-template-columns: 4rem 1fr auto auto;
  gap: 1.2rem;
  align-items: center;
  text-decoration: none;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  transition: background 150ms ease;
  color: inherit;
}

.seerr-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.seerr-row-poster {
  width: 4rem;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.seerr-poster-empty {
  background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.1));
}

.seerr-row-main {
  min-width: 0;
}

.seerr-row-title {
  color: var(--color-text-highlight);
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seerr-row-meta {
  margin-top: 0.2rem;
  color: var(--color-text-subdue);
  font-size: 1.05rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.seerr-row-meta > * + *::before {
  content: "•";
  margin-right: 0.6rem;
}

.seerr-row-status {
  display: flex;
  align-items: center;
}

.seerr-row-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.seerr-row-avatar {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05);
}

.seerr-row-user-name {
  font-size: 1.15rem;
  color: var(--color-text-base);
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sur containers étroits (colonne small / mobile) on cache le pseudo, on garde
   juste l'avatar pour ne pas casser la grille. */
@container widget (max-width: 700px) {
  .seerr-row { grid-template-columns: 3.5rem 1fr auto auto; gap: 0.8rem; }
  .seerr-row-user-name { display: none; }
}

.seerr-badge {
  font-size: 1rem;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.seerr-badge-pending     { background: rgba(220, 160,  40, 0.85); }
.seerr-badge-approved    { background: rgba( 80, 130, 200, 0.85); }
.seerr-badge-processing  { background: rgba(110,  80, 200, 0.85); }
.seerr-badge-available   { background: rgba( 60, 160,  90, 0.85); }
.seerr-badge-declined    { background: rgba(190,  60,  60, 0.85); }

/* ============================================================
   WIDGET PLEX — sessions actives en temps réel
   ============================================================ */

.plex-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.plex-row {
  display: grid;
  grid-template-columns: 4rem 1fr auto;
  gap: 1.2rem;
  align-items: center;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.plex-row-poster {
  width: 4rem;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.plex-row-main {
  min-width: 0;
}

.plex-row-title {
  color: var(--color-text-highlight);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plex-row-meta {
  margin-top: 0.25rem;
  color: var(--color-text-base);
  font-size: 1.05rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
}

.plex-state {
  font-weight: 500;
}

.plex-state-playing  { color: hsl(142, 60%, 60%); }
.plex-state-paused   { color: hsl( 43, 70%, 65%); }
.plex-state-buffering{ color: hsl(210, 70%, 65%); }

.plex-transcode {
  font-size: 0.95rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: rgba(170, 100, 200, 0.25);
  color: hsl(280, 60%, 80%);
  border: 1px solid rgba(170, 100, 200, 0.4);
}

.plex-progress {
  margin-top: 0.45rem;
  height: 0.35rem;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  overflow: hidden;
}

.plex-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, hsl(43, 80%, 60%), hsl(28, 90%, 60%));
  border-radius: 999px;
  transition: width 1s linear;
}

.plex-row-user {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
  max-width: 7rem;
}

.plex-row-avatar {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.05);
}

.plex-row-user-name {
  font-size: 1rem;
  color: var(--color-text-base);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

@container widget (max-width: 700px) {
  .plex-row { grid-template-columns: 3.5rem 1fr auto; gap: 0.8rem; }
  .plex-row-user-name { display: none; }
}

/* ============================================================
   NAVBAR — recherche Google (injectée par nav-google-search.js)
   ============================================================ */

/* Le header Glance est en flex : la barre est centrée en position absolue. */
.header {
  position: relative;
}

.nav-google-search form {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  height: 3.5rem;
}

.nav-google-search-logo {
  width: 2.65rem;
  height: 2.65rem;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

/* Desktop : centré dans toute la barre du haut */
.nav-google-search--bar {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  margin: 0;
  padding: 0;
  border: none;
  pointer-events: auto;
}

.nav-google-search-input {
  width: min(24rem, 36vw);
  min-width: 12rem;
  font: inherit;
  font-size: 1.45rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: var(--color-text-highlight);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.nav-google-search-input::placeholder {
  color: var(--color-text-subdue);
}

.nav-google-search-input:focus {
  border-color: rgba(217, 95, 72, 0.55);
  box-shadow: 0 0 0 2px rgba(217, 95, 72, 0.2);
}

.nav-google-search-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: rgba(217, 95, 72, 0.35);
  color: var(--color-text-highlight);
  transition: background 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}

.nav-google-search-submit:hover {
  background: rgba(217, 95, 72, 0.55);
}

.nav-google-search-submit:active {
  transform: scale(0.96);
}

/* Menu pages mobile */
.nav-google-search--mobile {
  margin: 1rem 0 0.5rem;
  padding: 0 0.35rem;
  position: static;
  transform: none;
  left: auto;
  top: auto;
  z-index: auto;
}

.nav-google-search--mobile form {
  height: auto;
  flex-wrap: wrap;
}

.nav-google-search--mobile .nav-google-search-input {
  flex: 1;
  min-width: 0;
  width: auto;
  max-width: none;
  font-size: 1.35rem;
}

.nav-google-search--mobile form {
  width: 100%;
}

.nav-google-search--mobile .nav-google-search-logo {
  width: 2.4rem;
  height: 2.4rem;
}

.nav-google-search--mobile .nav-google-search-submit {
  width: 3.2rem;
  height: 3.2rem;
}

/* ============================================================
   TITRES DE WIDGETS — petites icônes discrètes (pas de support
   natif `icon:` sur calendrier / météo / RSS dans Glance).
   ============================================================ */

.widget-header h2 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.widget-header h2::before {
  flex-shrink: 0;
  font-size: 0.92em;
  line-height: 1;
  opacity: 0.48;
  font-weight: 400;
  letter-spacing: 0;
}

.widget.widget-type-calendar > .widget-header h2::before {
  content: "📅";
}
.widget.widget-type-weather > .widget-header h2::before {
  content: "🌤️";
}
.widget.widget-type-monitor > .widget-header h2::before {
  content: "📡";
}
.widget.section-admin-bookmarks > .widget-header h2::before {
  content: "🛠️";
}
.widget.section-rss-tech > .widget-header h2::before {
  content: "📰";
}
.widget.section-plex-activity > .widget-header h2::before {
  content: "▶️";
}
.widget.section-seerr-requests > .widget-header h2::before {
  content: "📋";
}
.widget.section-plex-bookmarks > .widget-header h2::before {
  content: "🔗";
}
.widget.section-docker > .widget-header h2::before {
  content: "🐳";
}
.widget.section-releases-media > .widget-header h2::before {
  content: "🎬";
}
.widget.section-releases-infra > .widget-header h2::before {
  content: "⚙️";
}

/* Titres de sections HTML (Tech / Plex) */
.section-heading-with-icon {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.section-heading-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2em;
  height: 1.2em;
  font-size: 0.88em;
  opacity: 0.48;
  font-weight: 500;
}

/* ============================================================
   PLIAGE DES WIDGETS — voir collapse.js
   ============================================================ */

.collapsible-widget .collapsible-header {
  position: relative;
  user-select: none;
}

.collapsible-widget .collapsible-chevron {
  display: inline-block;
  margin-left: 0.5rem;
  transition: transform 200ms ease;
  font-size: 0.85em;
  opacity: 0.7;
}

.collapsible-widget.is-collapsed .collapsible-chevron {
  transform: rotate(-90deg);
}

/* Cache tout sauf le header quand replié */
.collapsible-widget.is-collapsed > *:not(.collapsible-header):not(:first-child) {
  display: none !important;
}
