/* Page Astrophoto */

/* Couleurs de la page. En thème sombre, le vert vif est remplacé par le vert sombre de la tuile Observation
   (#29302a, = --field) pour les aplats ; les traits fins (cadre, sélection, heure de la carte), qui
   disparaîtraient dans ce vert sur le ciel noir, prennent la couleur du texte. Le thème rouge ne change pas. */
.ap-board { --ap-line: var(--accent); }
:root:not([data-theme='night']) .ap-board {
  --accent: #29302a;
  --accent-ink: var(--ink);
  --ap-line: var(--ink);
}
:root:not([data-theme='night']) .ap-board :focus-visible { outline-color: var(--ink); }
:root:not([data-theme='night']) .ap-board input[type='range']::-moz-range-track { background: var(--bg); }
:root:not([data-theme='night']) .ap-board input[type='range']::-webkit-slider-runnable-track { background: var(--bg); }
:root:not([data-theme='night']) .ap-board input[type='range']::-moz-range-thumb { background: var(--ink); }
:root:not([data-theme='night']) .ap-board input[type='range']::-webkit-slider-thumb { background: var(--ink); }
:root:not([data-theme='night']) .ap-board input[type='range']:focus-visible { outline-color: var(--ink); }
:root:not([data-theme='night']) .ap-wx-table tr[data-dark='true'] td { background: var(--field); }
/* Nuit sans Lune : bande pleine hauteur dans ce vert ; en rouge, bande sombre et trait rouge en bas. */
.nb-band, .cv-band { fill: var(--field); }
:root:not([data-theme='night']) .nb-dark, :root:not([data-theme='night']) .cv-dark { display: none; }
:root:not([data-theme='night']) .k-dark::before { height: 14px !important; background: var(--field); }
:root:not([data-theme='night']) .ap-wx-table tr[data-dark='true'] td:first-child { color: var(--ink); }

/* En-tête : titre, lieu, date et heure de la carte */
.ap-top { display: grid; grid-template-columns: 1fr auto; gap: 12px 24px; align-items: end; }
.ap-title { display: grid; gap: 4px; }
.ap-title h1 { font-weight: 600; }
.ap-when { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.ap-when label { display: grid; gap: 4px; }
.ap-when .field { width: auto; min-width: 9.5rem; background: var(--tile); }
.ap-when .button { background: var(--tile); }
.ap-when .button[aria-pressed='true'], .ap-auto[aria-pressed='true'] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.ap-slider { grid-column: 1 / -1; }
.ap-slider input { width: 100%; min-height: 36px; }

/* La carte */
.ap-chart { position: relative; background: var(--sky-night); }
.ap-canvas {
  width: 100%;
  height: clamp(420px, 74vh, 880px);
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
/* Sur ordinateur, la carte remplit toute sa tuile, même quand la colonne de droite (objet choisi, curseur)
   est plus haute qu'elle : sinon il restait une bande noire sous le canvas. */
@media (min-width: 1081px) {
  .ap-chart { min-height: clamp(420px, 74vh, 880px); }
  .ap-chart .ap-canvas { position: absolute; inset: 0; height: 100%; }
}
.ap-canvas:active { cursor: grabbing; }
.ap-canvas:focus-visible { outline-offset: -3px; }
.ap-zoom { position: absolute; right: 10px; top: 10px; display: grid; gap: 4px; }
.ap-zoom button {
  width: 44px; height: 44px;
  border: 0; background: var(--tile-2); color: var(--ink);
  font-size: 1.4rem; line-height: 1; cursor: pointer;
  transition: background-color var(--t-hover) ease;
}
.ap-zoom button:hover { background: var(--field); }
.ap-fov {
  position: absolute; left: 0; top: 0; padding: 8px 12px;
  background: var(--sky-night); color: var(--muted); pointer-events: none;
}

/* Coordonnées du point touché, affichées sur la carte (téléphone). */
.ap-tap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 12px 10px;
  background: var(--tile-2); display: flex; flex-wrap: wrap; gap: 2px 14px; pointer-events: none;
}
.ap-tap b { font-weight: 600; flex: 1 1 100%; }
.ap-tap span { font-family: var(--mono); font-variant-numeric: tabular-nums slashed-zero; white-space: nowrap; }

/* Colonne : recherche, objet choisi, coordonnées sous le curseur */
.ap-side { display: grid; gap: 28px; align-content: start; }
.ap-search { display: grid; gap: 6px; }
.ap-results:empty { display: none; }
.ap-results button { display: grid; gap: 0; }
.ap-results button[aria-selected='true'] { background: var(--field); }
.ap-pick { display: grid; gap: 8px; }
.ap-pick h2 { font-weight: 600; }
.ap-pick .button { justify-self: start; min-height: 44px; }
.ap-cursor { display: grid; gap: 8px; }
.ap-dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; align-items: baseline; }
.ap-dl dt { font-size: var(--step-small); color: var(--muted); }
.ap-dl dd { font-family: var(--mono); font-variant-numeric: tabular-nums slashed-zero; font-size: 0.95rem; white-space: nowrap; }
.ap-dl dd.txt { font-family: var(--font); white-space: normal; }

/* Cadre de champ */
.ap-frame { display: grid; gap: 16px; }
.ap-frame-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
/* État de l'image du ciel, sous la légende de la carte. */
.ap-dss { position: absolute; left: 0; top: 34px; padding: 6px 12px; max-width: min(100%, 460px); background: var(--sky-night); color: var(--muted); pointer-events: none; }
.ap-dss[data-state='error'] { color: var(--ink); }
.ap-dss-note { margin-top: 8px; }
.ap-frame-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; }
.ap-frame-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; align-items: end; }
.ap-field { display: grid; gap: 4px; min-width: 0; }
.ap-field--wide { grid-column: span 2; }
.ap-field .field { background: var(--bg); }
.ap-angle-row { display: flex; gap: 8px; align-items: center; }
.ap-angle-row input[type='range'] { flex: 1; min-height: 44px; }
.ap-angle-row .field { width: 5.5rem; flex: 0 0 auto; }
.ap-frame-out { max-width: 640px; gap: 4px 16px; }
/* Cadre : résultats à gauche, mosaïque à droite (l'une sous l'autre sur écran étroit). */
.ap-frame-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 16px 32px; align-items: stretch; }
/* Les boutons du cadre descendent en bas de la colonne quand la mosaïque, à côté, est plus haute. */
.ap-frame-main { display: grid; gap: 16px; grid-template-rows: auto auto 1fr; }
.ap-mosaic { display: grid; gap: 12px; align-content: start; background: var(--tile-2); padding: 16px 18px; min-width: 0; }
.ap-mosaic h3 { font-size: 1.15rem; font-weight: 600; }
.ap-mosaic-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; align-items: end; }
.ap-mosaic .button { justify-self: start; background: var(--tile); }
.ap-mosaic-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ap-mosaic .ap-auto:not([aria-pressed='true']) { background: var(--tile); }
.ap-mosaic-table td, .ap-mosaic-table th { padding-block: 6px; }
.ap-mosaic-table .button { min-height: 36px; padding: 6px 12px; font-size: var(--step-small); }
@media (max-width: 900px) { .ap-frame-body { grid-template-columns: minmax(0, 1fr); } }
/* Téléphone : la déclinaison passe sous l'ascension droite, pour que l'angle et « Copier » restent visibles. */
@media (max-width: 600px) {
  .ap-mosaic { padding: 12px; }
  .ap-mosaic-table tr {
    display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) auto auto; column-gap: 10px; align-items: center;
    grid-template-areas: 'n ra ang btn' 'n dec ang btn'; border-bottom: 1px solid var(--rule); padding-block: 6px;
  }
  .ap-mosaic-table th, .ap-mosaic-table td { border: 0; padding-block: 1px; }
  .ap-mosaic-table :is(th, td):nth-child(1) { grid-area: n; }
  .ap-mosaic-table th:nth-child(1) { visibility: hidden; } /* « Panneau » ne tient pas ; les numéros parlent d'eux-mêmes */
  .ap-mosaic-table :is(th, td):nth-child(2) { grid-area: ra; }
  .ap-mosaic-table :is(th, td):nth-child(3) { grid-area: dec; }
  .ap-mosaic-table :is(th, td):nth-child(4) { grid-area: ang; }
  .ap-mosaic-table :is(th, td):nth-child(5) { grid-area: btn; }
}
.ap-frame-actions { display: flex; flex-wrap: wrap; gap: 8px; align-self: end; }
.ap-frame-actions .button { background: var(--tile-2); }
.ap-frame-actions .button:disabled { opacity: 0.45; cursor: default; }

/* Séance : nuits noires */
/* Les tuiles en grille ne s'élargissent pas au contenu (frises SVG, tableaux) : elles restent dans l'écran. */
.ap-nights, .ap-suggest, .ap-calc, .ap-frame, .ap-curve-tile, .ap-wx, .ap-side { grid-template-columns: minmax(0, 1fr); }
.ap-night-list li, .ap-night-list button, .ap-sug-list li { min-width: 0; }
.ap-sec-head { display: grid; gap: 6px; max-width: 78ch; }
.ap-sec-head h2, .ap-frame-head h2 { font-size: var(--step-lead); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.ap-nights { display: grid; gap: 14px; }
.ap-keys { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); }
.ap-keys .k { display: inline-flex; align-items: center; gap: 6px; }
.ap-keys .k::before { content: ''; width: 14px; height: 14px; }
.k-twi::before { background: var(--sky-naut); }
.k-astro::before { background: var(--sky-night); outline: 1px solid var(--rule); }
.k-moon::before { background: var(--moon-lit); opacity: 0.45; }
.k-dark::before { height: 4px !important; background: var(--accent); }
.ap-night-list { display: grid; gap: 4px; }
.ap-night-list button {
  display: grid; grid-template-columns: 9.5rem minmax(120px, 1fr) auto; gap: 6px 14px; align-items: center;
  width: 100%; min-height: 48px; padding: 8px 12px; border: 0; background: var(--tile-2); color: var(--ink);
  text-align: left; cursor: pointer; transition: background-color var(--t-hover) ease;
}
.ap-night-list button:hover { background: var(--field); }
.ap-night-list button[aria-pressed='true'] { background: var(--field); box-shadow: inset 4px 0 0 var(--ap-line); }
.ap-night-bar { width: 100%; height: 22px; display: block; }
.ap-night-info { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ap-night-dark .num, .ap-sug-num .num { white-space: nowrap; }
.ap-night-moon { color: var(--muted); font-size: var(--step-small); text-align: right; white-space: nowrap; }
.nb-day { fill: var(--sky-day); } .nb-civil { fill: var(--sky-civil); } .nb-naut { fill: var(--sky-naut); }
.nb-astro { fill: var(--sky-astro); } .nb-night { fill: var(--sky-night); }
.nb-moon { fill: var(--moon-lit); opacity: 0.45; }
.nb-dark { fill: var(--accent); }

/* Courbe de hauteur */
/* La courbe prend toute la hauteur laissée par la tuile Météo voisine (redessinée à sa taille réelle). */
.ap-curve-tile { display: flex; flex-direction: column; gap: 12px; }
.ap-curve { flex: 1 1 0; width: 100%; min-height: clamp(230px, 26vw, 330px); cursor: crosshair; touch-action: pan-y; display: block; }
.cv-grid { stroke: var(--rule); stroke-width: 1; }
.cv-label { font-family: var(--mono); font-size: 13px; fill: var(--muted); }
.cv-obj { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }
.cv-moon { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 7 6; }
.cv-transit { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 2 4; }
.cv-transit-label { font-family: var(--font); font-size: 14px; fill: var(--ink); }
.cv-now { stroke: var(--ap-line); stroke-width: 2.5; }
.cv-dark { fill: var(--accent); }

/* Météo de la nuit */
.ap-wx { display: grid; gap: 12px; align-content: start; }
.ap-wx-table td, .ap-wx-table th { padding-block: 7px; }
.ap-wx-table td { font-size: 0.9rem; }
.ap-wx-table tbody tr { cursor: default; }
.ap-wx-table tr[data-dark='true'] td:first-child { color: var(--accent); font-weight: 500; }

/* Suggestions */
.ap-suggest { display: grid; gap: 14px; }
.ap-sug-list { display: grid; gap: 4px; }
.ap-sug-list li {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 4px 18px; align-items: center;
  background: var(--tile-2); padding: 10px 12px;
}
.ap-sug-name { font-weight: 600; }
.ap-sug-meta { color: var(--muted); font-size: var(--step-small); }
.ap-sug-num { font-size: 0.95rem; }
.ap-sug-list .button { min-height: 40px; padding: 8px 14px; background: var(--tile); }

/* Calculateurs */
.ap-calc { display: grid; gap: 14px; align-content: start; }
.ap-field--inline { max-width: 18rem; }
.ap-results-big { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 24px; }
.ap-results-big div { display: grid; gap: 2px; }
.ap-results-big dt { font-size: var(--step-small); color: var(--muted); }
.ap-results-big dd { font-family: var(--mono); font-variant-numeric: tabular-nums slashed-zero; font-size: var(--step-lead); line-height: 1.15; }

/* Réglages d'affichage */
.ap-layers { display: flex; flex-wrap: wrap; gap: 18px 32px; align-items: start; }
.ap-group { display: grid; gap: 6px; }
.ap-group .segmented { flex-wrap: wrap; }
.ap-mag { min-width: min(100%, 300px); }
.ap-mag-row { display: flex; gap: 8px; align-items: center; }
.ap-mag-row input { flex: 1; min-height: 44px; }
.ap-auto {
  border: 0; background: var(--tile-2); padding: 10px 14px; min-height: 44px; cursor: pointer;
  font-size: var(--step-small);
}

@media (max-width: 1080px) {
  .ap-chart, .ap-side, .ap-curve-tile, .ap-wx { grid-column: span 12; }
  .ap-side { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 860px) {
  .ap-night-list button { grid-template-columns: minmax(0, 1fr); gap: 6px; padding-block: 10px; }
  .ap-sug-list li { grid-template-columns: 1fr auto; }
  .ap-sug-list li > :nth-child(2), .ap-sug-list li > :nth-child(3) { grid-column: 1 / -1; }
  .ap-sug-list li .button { grid-row: 1; grid-column: 2; }
}
@media (max-width: 640px) {
  .ap-wx-table th:nth-child(3), .ap-wx-table td:nth-child(3) { display: none; }
  .ap-field--wide { grid-column: 1 / -1; }
  .ap-frame-grid { grid-template-columns: 1fr 1fr; }
  .ap-top { grid-template-columns: 1fr; }
  .ap-when .field { min-width: 0; flex: 1 1 8rem; }
  .ap-when label { flex: 1 1 8rem; }
  .ap-canvas { height: 68vh; min-height: 360px; }
  .ap-layers { gap: 14px; }
}

/* Thème rouge : rien de vif. Les boutons actifs restent sombres, leur texte porte la couleur. */
[data-theme='night'] .ap-when .button[aria-pressed='true'],
[data-theme='night'] .ap-auto[aria-pressed='true'] { background: #260906; color: var(--accent); }
