/* Théochrone — feuille de style unique.
   Remplace Bootstrap 3, Font Awesome, animate.css et le gabarit « Worthy ».
   Aucune dépendance, aucune police distante. */

/* ============================================================ jetons */

:root {
  color-scheme: light dark;

  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --surface-2: #eef0f4;
  --line:      #dde1e8;
  --line-soft: #e9ecf1;
  --text:      #14171c;
  --muted:     #616b7b;
  --accent:    #7a5e1b;
  --accent-on: #ffffff;

  /* couleurs liturgiques */
  --lit-blanc:  #b28f2e;
  --lit-rouge:  #b23b43;
  --lit-vert:   #2f7d59;
  --lit-violet: #6a4aa0;
  --lit-noir:   #43484f;
  --lit-rose:   #c26d92;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;

  --lit: var(--line);   /* couleur liturgique par défaut, écrasée par .lit-* */

  --rail: 15rem;
  --aside: 24rem;
  --radius: 10px;
  --shadow: 0 1px 2px #0000000f, 0 8px 24px #00000012;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0e1013;
    --surface:   #16191e;
    --surface-2: #1d2128;
    --line:      #272c34;
    --line-soft: #1f242b;
    --text:      #e7eaf0;
    --muted:     #8b95a5;
    --accent:    #c8a24a;
    --accent-on: #14171c;
    --lit-blanc:  #e8dcae;
    --lit-rouge:  #d0555c;
    --lit-vert:   #4f9d76;
    --lit-violet: #8f6fc0;
    --lit-noir:   #7d838d;
    --lit-rose:   #dd8fb0;
    --shadow: 0 1px 2px #00000040, 0 8px 24px #00000050;
  }
}

:root[data-theme="dark"] {
  --bg:        #0e1013;
  --surface:   #16191e;
  --surface-2: #1d2128;
  --line:      #272c34;
  --line-soft: #1f242b;
  --text:      #e7eaf0;
  --muted:     #8b95a5;
  --accent:    #c8a24a;
  --accent-on: #14171c;
  --lit-blanc:  #e8dcae;
  --lit-rouge:  #d0555c;
  --lit-vert:   #4f9d76;
  --lit-violet: #8f6fc0;
  --lit-noir:   #7d838d;
  --lit-rose:   #dd8fb0;
  --shadow: 0 1px 2px #00000040, 0 8px 24px #00000050;
}

/* la couleur liturgique d'un élément, posée par une classe du gabarit */
.lit-blanc  { --lit: var(--lit-blanc); }
.lit-rouge  { --lit: var(--lit-rouge); }
.lit-vert   { --lit: var(--lit-vert); }
.lit-violet { --lit: var(--lit-violet); }
.lit-noir   { --lit: var(--lit-noir); }
.lit-rose   { --lit: var(--lit-rose); }

/* ============================================================ base */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: .15em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.skip {
  position: absolute; left: -9999px; z-index: 20;
  background: var(--surface); padding: .6rem 1rem; border-radius: 8px;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ============================================================ ossature */

.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100dvh;
}

/* --- rail (bureau) / barre d'onglets (mobile) --- */

.rail {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 1.1rem .9rem;
  display: flex; flex-direction: column; gap: 1.4rem;
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
}

.brand { display: flex; gap: .6rem; align-items: center; padding: 0 .3rem; text-decoration: none; color: inherit; }
.brand .mark { color: var(--accent); font-size: 1.4rem; line-height: 1; }
.brand .name { font-weight: 600; line-height: 1.15; }
.brand small { display: block; font-weight: 400; font-size: .7rem; color: var(--muted); letter-spacing: .03em; }

.railnav { display: flex; flex-direction: column; gap: 1px; }
.railnav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .5rem .55rem; border-radius: 7px;
  color: var(--muted); text-decoration: none;
}
.railnav a .ico { width: 1.1rem; text-align: center; }
.railnav a small { display: block; font-size: .7rem; letter-spacing: .03em; line-height: 1.2; }
.railnav a:hover { background: var(--surface-2); color: var(--text); }
.railnav a.is-current { background: var(--surface-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }

.railgroup { display: flex; flex-direction: column; gap: .7rem; padding: 0 .3rem; }
.railgroup > .label,
.legend-title {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}

.legend ul { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .3rem .5rem; font-size: .76rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: .4rem; }
.legend i { width: .6rem; height: .6rem; border-radius: 3px; background: var(--lit); flex: none; }

.railfoot { margin-top: auto; display: flex; flex-direction: column; gap: .6rem; }
.railfoot p { margin: 0; font-size: .72rem; color: var(--muted); }
.railfoot a { color: var(--muted); }

/* --- scène --- */

.stage {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--aside);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "bar    bar"
    "main   aside";
  align-content: start;
}
.stagebar { grid-area: bar; }
.stagemain { grid-area: main; min-width: 0; padding: 1.1rem 1.4rem 3rem; }
.stageaside { grid-area: aside; min-width: 0; }

.stagebar {
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
  padding: .8rem 1.4rem; border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 4;
}
.stagebar h1 { font-size: 1.1rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }

.periodnav { display: flex; align-items: center; gap: .3rem; }
.periodnav > a, .periodnav > button {
  display: grid; place-items: center;
  width: 2rem; height: 2rem; border-radius: 7px;
  border: 1px solid transparent; background: none; cursor: pointer;
  color: var(--muted); text-decoration: none; font-size: 1.15rem; line-height: 1;
}
.periodnav > a:hover, .periodnav > button:hover { background: var(--surface-2); color: var(--text); }
.periodnav .now { width: auto; padding: 0 .7rem; font-size: .82rem; border-color: var(--line); }
.periodnav .title { margin: 0 .5rem; min-width: 8.5rem; }

/* ============================================================ formulaires */

.field, .btn {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .42rem .6rem;
}
select.field { cursor: pointer; }
.btn { cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-on); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { color: var(--accent-on); filter: brightness(1.06); }

.check { display: flex; gap: .5rem; align-items: flex-start; font-size: .84rem; color: var(--muted); }
.check input { margin: .25rem 0 0; flex: none; }

.searchform { margin-left: auto; display: flex; gap: .4rem; }
.searchform input[type="search"] { width: 17rem; max-width: 100%; }

/* formulaires Django rendus par as_p */
.form p { margin: 0 0 .9rem; }
.form label { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .25rem; }
.form label.check { text-transform: none; letter-spacing: 0; font-size: .84rem; }
.form input:not([type="checkbox"]):not([type="radio"]), .form select, .form textarea {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: .42rem .6rem;
  max-width: 100%;
}
.form textarea { width: 100%; min-height: 9rem; }
.form ul { list-style: none; padding: 0; margin: 0; }
.form .hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form label small { text-transform: none; letter-spacing: 0; }
.form .helptext { display: block; font-size: .76rem; color: var(--muted); }
.form .errorlist { color: var(--lit-rouge); font-size: .8rem; padding: 0; margin: 0 0 .4rem; list-style: none; }

/* ============================================================ grille du mois */

.weekdays, .grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px;
}
.weekdays {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); padding-bottom: .5rem;
}
.weekdays span { padding-left: .45rem; }

.cell {
  position: relative; min-width: 0; min-height: 6.4rem;
  display: flex; flex-direction: column; gap: .3rem;
  padding: .45rem .5rem .5rem; text-align: left; text-decoration: none;
  color: inherit; background: var(--surface);
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  transition: border-color .12s ease;
}
.cell::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(to bottom, color-mix(in oklab, var(--lit) 16%, transparent), transparent 62%);
}
.cell:hover { border-color: color-mix(in oklab, var(--lit) 55%, var(--line)); }
.cell.is-selected { border-color: var(--lit); box-shadow: 0 0 0 1px var(--lit); }
.cell.is-outside { opacity: .4; }
.cell.is-today .daynum { background: var(--accent); color: var(--accent-on); }

.daynum {
  position: relative; z-index: 1;
  font-size: .76rem; font-weight: 600;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  display: grid; place-items: center;
}
.rankmark {
  position: absolute; top: .5rem; right: .55rem; z-index: 1;
  font-family: var(--mono); font-size: .6rem; letter-spacing: .04em; color: var(--muted);
}
.cell .entries { position: relative; z-index: 1; display: flex; flex-direction: column; gap: .18rem; min-width: 0; }
.entry { display: flex; gap: .35rem; align-items: baseline; font-size: .73rem; line-height: 1.25; min-width: 0; }
.entry .dot { width: .38rem; height: .38rem; border-radius: 50%; background: var(--lit); flex: none; translate: 0 -.12em; }
.entry b { font-weight: 400; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry.is-com b { color: var(--muted); }

/* ============================================================ panneau du jour */

.stageaside { border-left: 1px solid var(--line); background: var(--surface); }
.aside-inner { padding: 1.2rem 1.2rem 3rem; position: sticky; top: 3.6rem; }

.dhead { margin-bottom: 1.2rem; }
.dhead .periodnav { align-items: start; gap: .15rem; margin-bottom: .1rem; }
.dhead .periodnav > a { flex: none; }
.dhead h2 { flex: 1; min-width: 0; margin: 0; padding-top: .1rem; font-size: 1.02rem; font-weight: 600; text-wrap: balance; }
.dhead h2 a { color: inherit; text-decoration: none; }
.dhead h2 a:hover { text-decoration: underline; }
.dhead p { margin: .2rem 0 0; font-size: .8rem; color: var(--muted); }

.card {
  background: var(--surface-2); border: 1px solid var(--line);
  border-left: 3px solid var(--lit); border-radius: var(--radius);
  padding: .85rem .95rem; margin-bottom: .8rem;
}
.card > h3 { margin: 0 0 .1rem; font-size: .96rem; font-weight: 600; line-height: 1.3; }
.card .la { margin: 0 0 .7rem; font-family: var(--serif); font-style: italic; font-size: .86rem; color: var(--muted); }
.card figure { margin: 0 0 .8rem; }
.card figure img { border-radius: 7px; display: block; width: 100%; }
.card figcaption { font-size: .72rem; color: var(--muted); margin-top: .3rem; }

.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .7rem; }
.tag {
  font-size: .67rem; letter-spacing: .04em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 999px; padding: .1rem .5rem; color: var(--muted);
}
.tag.lit { border-color: var(--lit); color: var(--lit); }
/* the text of the tag, mixed with the text colour: the gold of 'blanc' alone is too pale to read */
.tag.lit { color: color-mix(in srgb, var(--lit) 65%, var(--text)); }
.tag sup { text-transform: none; } /* IVᵉ classe, pas IVE CLASSE */

.card dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; margin: 0 0 .7rem; font-size: .79rem; }
.card dt { color: var(--muted); }
.card dd { margin: 0; }
.card .read { font-size: .79rem; }

/* ============================================================ liste de résultats */

.hits { display: flex; flex-direction: column; gap: .4rem; max-width: 46rem; }
.hit {
  display: grid; grid-template-columns: 7rem 1fr; gap: 1rem; align-items: baseline;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--lit);
  border-radius: 8px; padding: .6rem .85rem; text-decoration: none; color: inherit;
}
.hit:hover { background: var(--surface-2); }
.hit time { font-size: .78rem; color: var(--muted); }
.hit b { font-weight: 500; }
.hit .la { display: block; font-family: var(--serif); font-style: italic; color: var(--muted); font-size: .82rem; }

/* ============================================================ martyrologe */

.marty { max-width: 44rem; }
.marty ol { list-style: none; counter-reset: elogium; padding: 0; margin: 1.2rem 0 0; }
.marty li {
  counter-increment: elogium; position: relative; padding-left: 2.2rem;
  margin-bottom: 1.1rem; text-align: justify; hyphens: auto;
}
.marty li::before {
  content: counter(elogium); position: absolute; left: 0; top: .15rem;
  font-size: .7rem; color: var(--accent);
}
.marty mark { background: color-mix(in oklab, var(--accent) 28%, transparent); color: inherit; padding: 0 .15em; border-radius: 3px; }
.marty .last { font-style: italic; color: var(--muted); border-top: 1px solid var(--line); padding-top: 1rem; }
.marty .credits { font-size: .78rem; color: var(--muted); }

/* ============================================================ pages de contenu */

.prose { max-width: 44rem; }
.prose h2 { font-size: 1.25rem; font-weight: 600; margin: 2rem 0 .6rem; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 1rem; font-weight: 600; margin: 1.6rem 0 .4rem; }
.prose p, .prose li { color: var(--text); }
.prose .lede { color: var(--muted); }
.prose ul, .prose ol { padding-left: 1.2rem; }
.prose li { margin-bottom: .3rem; }
.prose code, .prose pre {
  font-family: var(--mono); font-size: .84em;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px;
}
.prose code { padding: .1em .35em; }
.prose pre { padding: .8rem 1rem; overflow-x: auto; }
.prose pre code { background: none; border: 0; padding: 0; }
.prose table { border-collapse: collapse; width: 100%; }
.prose th, .prose td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); }

/* le choix de l'édition du martyrologe */
.editions { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1.2rem 0 0; }
.editions > * {
  padding: .18rem .55rem; border: 1px solid var(--line); border-radius: 999px;
  font-size: .78rem; text-decoration: none; color: var(--muted);
}
.editions > a:hover { border-color: var(--accent); color: var(--text); }
.editions .current { border-color: var(--accent); color: var(--text); font-weight: 600; }

.note {
  background: var(--surface-2); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
  padding: .9rem 1.1rem; margin: 1.2rem 0;
}
.note p:first-child { margin-top: 0; }
.note p:last-child { margin-bottom: 0; }

.cols { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.cols > div { min-width: 0; }

/* le code du widget : lisible et sélectionnable d'un coup */
.prose textarea {
  width: 100%; font-family: var(--mono); font-size: .8rem; line-height: 1.5;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: .7rem .8rem;
  resize: vertical;
}
.widget-demo {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 1rem; margin: .6rem 0 0; max-width: 26rem;
}
.linklist { list-style: none; padding: 0; margin: 0; }
.linklist li { border-bottom: 1px solid var(--line); }
.linklist a { display: block; padding: .55rem .1rem; text-decoration: none; }
.linklist a:hover { text-decoration: underline; }

.empty { color: var(--muted); }

/* ============================================================ mobile */

@media (max-width: 78rem) {
  :root { --aside: 20rem; }
  .searchform input[type="search"] { width: 12rem; }
}

@media (max-width: 60rem) {
  .shell { grid-template-columns: 1fr; }

  /* Sur mobile la scène s'empile, et le résultat vient AVANT le calendrier :
     l'ordre du DOM est déjà celui-là, le bureau le réordonne par grid-area. */
  .stage {
    grid-template-columns: 1fr;
    grid-template-areas: "bar" "aside" "main";
  }
  .stagemain { padding: 0 .8rem 1.5rem; }
  .stageaside { border-left: 0; background: none; }
  .aside-inner { position: static; padding: 1rem .8rem 1.4rem; }

  .stagebar { padding: .7rem .8rem; gap: .6rem; }
  .stagebar h1 { font-size: 1rem; }
  .periodnav .title { min-width: 6.5rem; }
  .searchform { width: 100%; margin-left: 0; }
  .searchform input[type="search"] { flex: 1; width: auto; }

  /* la grille devient un aperçu compact : chiffres et couleurs seulement */
  .cell { min-height: 3.4rem; padding: .3rem .35rem; }
  .cell .entries, .rankmark { display: none; }
  .grid, .weekdays { gap: 4px; }
  .weekdays span { padding-left: .2rem; text-align: center; }
  .daynum { width: 1.4rem; height: 1.4rem; margin-inline: auto; }

  .hit { grid-template-columns: 1fr; gap: .15rem; }

  /* rail -> barre d'onglets collée en bas */
  .rail {
    position: fixed; inset: auto 0 0 0; height: auto; z-index: 6;
    flex-direction: row; align-items: center; gap: .2rem;
    border-right: 0; border-top: 1px solid var(--line);
    padding: .3rem .4rem calc(.3rem + env(safe-area-inset-bottom));
    overflow-x: auto;
  }
  .brand, .railgroup, .railfoot { display: none; }
  /* sept onglets tiennent dans 320 px : ils se partagent la largeur, le texte rétrécit avec l'écran */
  .railnav { flex-direction: row; width: 100%; justify-content: space-between; gap: 0; }
  .railnav a { flex: 1 1 auto; min-width: 0; flex-direction: column; gap: .1rem;
               font-size: clamp(.5rem, 2.55vw, .64rem); padding: .3rem .05rem; text-align: center; }
  .railnav a .ico { font-size: 1.05rem; }
  .railnav a small { display: none; }
  .railnav a.is-current { box-shadow: none; background: none; color: var(--accent); }
  body { padding-bottom: 4rem; }

  /* les réglages du rail réapparaissent en bas de la scène */
  .mobile-settings { display: block; }
}

.mobile-settings { display: none; }

@media (max-width: 60rem) {
  .mobile-settings {
    display: block; margin: 1.5rem .8rem 0; padding-top: 1rem;
    border-top: 1px solid var(--line);
  }
  .mobile-settings summary { cursor: pointer; font-size: .84rem; color: var(--muted); }
  .mobile-settings .railgroup { display: flex; margin-top: .9rem; padding: 0; }
  .mobile-settings .legend { display: block; }
}

@media print {
  .rail, .stagebar, .searchform, .mobile-settings { display: none; }
  .shell, .stage { display: block; }
  .stageaside { border: 0; }
  body { background: #fff; color: #000; }
}
