/* moon-phase — estilos propios. Los tokens y la base viven en assets/tokens.css */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  grid-template-areas: "stage deck";
  align-items: center;
  gap: var(--s-6);
}

/* Colores de la Luna. En oscuro la parte iluminada brilla y la sombra se funde
   con el cielo; sobre papel se dibuja como en un almanaque: la parte iluminada
   en un marfil cálido, la sombra en gris tinta y un contorno de tinta. */
:root {
  --moon-lit-0: #f4f6f8;
  --moon-lit-1: #dfe4ea;
  --moon-lit-2: #b4bcc6;
  --moon-mini: #d5dbe1;
  --moon-sea: #667079;
  --moon-glow: var(--text);
  --moon-shade: var(--bg);
  --moon-rim: var(--border-strong);
  --brand-lit: var(--text);
  --probe-window: var(--surface);
}

:root[data-theme="light"] {
  --moon-lit-0: #fffdf6;
  --moon-lit-1: #f8eed6;
  --moon-lit-2: #e6d5b0;
  --moon-mini: #fbf0d2;
  --moon-sea: #8a7758;
  --moon-glow: #d6b97f;
  --moon-shade: #59626d;
  --moon-rim: var(--rocket-line);
  --brand-lit: var(--moon-mini);
  --probe-window: var(--rocket-line);
}

/* ---------- marca ---------- */

.brand-lit {
  fill: var(--brand-lit);
}

.brand-shade {
  fill: var(--moon-shade);
  opacity: 0.9;
}

.brand-rim {
  stroke: var(--moon-rim);
}

.brand-star {
  fill: var(--accent);
}

/* ---------- escena ---------- */

.stage {
  grid-area: stage;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-4);
  min-width: 0;
}

.moon {
  width: clamp(250px, calc(100dvh - 432px), 440px);
  height: auto;
  aspect-ratio: 1;
  overflow: visible;
}

/* En el sur la Luna se ve girada 180°: mares y terminador a la vez. */
.moon-body {
  transition: transform var(--t-slow) var(--ease-in-out);
}

.moon.is-south .moon-body {
  transform: rotate(180deg);
}

.moon-lit-0 {
  stop-color: var(--moon-lit-0);
}

.moon-lit-1 {
  stop-color: var(--moon-lit-1);
}

.moon-lit-2 {
  stop-color: var(--moon-lit-2);
}

.moon-glow {
  stop-color: var(--moon-glow);
}

.moon-seas {
  fill: var(--moon-sea);
  opacity: 0.36;
}

.moon-rays {
  stroke: var(--rocket);
  opacity: 0.26;
}

.moon-craters {
  fill: var(--rocket);
  opacity: 0.6;
}

.moon-shadow {
  fill: var(--moon-shade);
  opacity: 0.9;
}

.moon-limb {
  fill: none;
  stroke: var(--moon-rim);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.moon-penumbra {
  fill: var(--moon-shade);
  opacity: 0.085;
}

.dial-gap {
  fill: var(--bg);
}

/* Cohete del dial: en modo claro lo sostiene un contorno de tinta, pintado por
   debajo del relleno para que solo asome por fuera. */
.probe-body {
  fill: var(--rocket);
  stroke: var(--rocket-line);
  stroke-width: 2;
  stroke-linejoin: round;
  paint-order: stroke;
  vector-effect: non-scaling-stroke;
}

.probe-side {
  fill: #cfd6dd;
}

.probe-fin {
  fill: var(--accent);
}

.probe-flame {
  fill: var(--alert);
}

.probe-window {
  fill: var(--probe-window);
}

/* Lunas pequeñas: dial, calendario y tarjetas */

.mini-disc {
  fill: var(--moon-mini);
}

.mini-shadow {
  fill: var(--moon-shade);
  opacity: 0.9;
}

.mini-rim {
  fill: none;
  stroke: var(--moon-rim);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.mini-ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
  opacity: 0;
}

.is-major > .mini-ring {
  opacity: 1;
}

/* ---------- lectura ---------- */

.readout {
  text-align: center;
}

.phase {
  margin: var(--s-1) 0;
  font-size: var(--fs-xl);
}

.note {
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, auto);
  justify-content: center;
  margin: 0;
}

.stat {
  padding: 0 var(--s-5);
  border-left: 1px solid var(--border);
}

.stat:first-child {
  border-left: 0;
}

.stat dt {
  white-space: nowrap;
}

.stat dd {
  margin: 2px 0 0;
  font-size: var(--fs-lg);
  font-weight: 500;
  white-space: nowrap;
}

.nexts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
  width: 100%;
  max-width: 600px;
}

.next {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "icon label"
    "icon when"
    "icon in";
  align-items: center;
  gap: 2px var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.next-icon {
  grid-area: icon;
}

.next-moon {
  width: 30px;
  height: 30px;
}

.next .console {
  grid-area: label;
  white-space: nowrap;
}

.next-when {
  grid-area: when;
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.next-in {
  grid-area: in;
  font-size: var(--fs-xs);
  color: var(--accent);
  white-space: nowrap;
}

/* Con sitio de sobra, la cuenta atrás sube a la derecha de la etiqueta */
@media (min-width: 1161px) {
  .next {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "icon label in"
      "icon when when";
  }
}

/* ---------- bitácora: fecha y calendario ---------- */

.deck {
  grid-area: deck;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-4);
}

.deck-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.seg {
  display: inline-flex;
  margin: 0;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.seg label {
  position: relative;
  cursor: pointer;
}

.seg input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.seg span {
  display: block;
  padding: 0 var(--s-3);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 26px;
  color: var(--text-2);
  transition:
    background-color var(--t-fast) var(--ease-out),
    color var(--t-fast) var(--ease-out);
}

/* Toque cómodo sin agrandar el control a la vista */
.seg label::after {
  content: "";
  position: absolute;
  inset: -9px 0;
}

.seg input:checked + span {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.seg input:focus-visible + span {
  outline: 2px solid var(--cold);
  outline-offset: 2px;
}

.date-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px auto;
  gap: var(--s-2);
}

.btn--icon {
  padding: 0;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.date-input {
  min-width: 0;
  min-height: 44px;
  padding: 0 var(--s-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  color: var(--text);
  transition: border-color var(--t-fast) var(--ease-out);
}

.date-input:hover {
  border-color: var(--border-strong);
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cal-title {
  font-size: var(--fs-md);
}

.cal-title::first-letter {
  text-transform: uppercase;
}

.cal-nav {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  color: var(--text-2);
  transition:
    color var(--t-fast) var(--ease-out),
    background-color var(--t-fast) var(--ease-out);
}

.cal-nav:hover {
  background: var(--surface-2);
  color: var(--text);
}

.cal-week,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-week {
  padding: var(--s-1) 0;
  font-size: var(--fs-xs);
  color: var(--text-2);
  text-align: center;
}

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 48px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out);
}

.cal-day:hover {
  background: var(--surface-2);
}

.cal-day:disabled {
  visibility: hidden;
}

.cal-num {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1;
  color: var(--text);
}

.cal-moon {
  width: 22px;
  height: 22px;
}

.cal-day.is-outside .cal-num {
  color: var(--text-2);
}

.cal-day.is-outside .cal-moon {
  opacity: 0.4;
}

.cal-day.is-today {
  border-color: var(--border-strong);
}

.cal-day.is-today .cal-num {
  color: var(--cold);
  font-weight: 600;
}

.cal-day.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.cal-events {
  display: flex;
  justify-content: space-around;
  margin: var(--s-3) 0 0;
  padding: var(--s-3) 0 0;
  border-top: 1px solid var(--border);
  list-style: none;
}

.cal-events li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: var(--fs-xs);
  line-height: 1.35;
}

.cal-event-moon {
  width: 22px;
  height: 22px;
  margin-bottom: 4px;
}

.cal-event-time {
  color: var(--text-2);
}

/* ---------- pantallas estrechas ---------- */

/* Columna estrecha: datos más compactos */
@media (max-width: 1160px) {
  .stat {
    padding: 0 var(--s-3);
  }

  .stat dd {
    font-size: var(--fs-md);
  }
}

@media (max-width: 980px) {
  .page {
    gap: var(--s-4);
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "stage"
      "deck";
    align-items: start;
    gap: var(--s-5);
  }

  .stage {
    gap: var(--s-3);
  }

  .stat {
    padding: 0 var(--s-5);
  }

  .stat dd {
    font-size: var(--fs-lg);
  }

  .moon {
    width: clamp(200px, 31dvh, 300px);
  }

  .deck {
    width: 100%;
    max-width: 460px;
    margin-inline: auto;
  }

  .deck-hint {
    display: none;
  }
}

@media (max-width: 560px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-3) 0;
    width: 100%;
  }

  .stat {
    padding: 0 var(--s-4);
    text-align: center;
  }

  .stat:nth-child(odd) {
    border-left: 0;
  }

  .next {
    grid-template-areas:
      "icon label"
      "when when"
      "in in";
    gap: var(--s-1) 6px;
    padding: var(--s-3) var(--s-2) var(--s-3) var(--s-3);
  }

  /* Sin el prompt la etiqueta cabe junto al icono a 360 px */
  .next .console::before {
    content: none;
  }

  .next-year {
    display: none;
  }

  .next-moon {
    width: 22px;
    height: 22px;
  }

  .next-when {
    font-size: var(--fs-xs);
  }
}

@media (max-width: 420px) {
  .deck {
    padding: var(--s-3) var(--s-2);
  }

  .deck-head,
  .date-row {
    padding-inline: var(--s-1);
  }
}

@media (hover: none) {
  .deck-hint {
    display: none;
  }
}
