@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #05060a;
  --fg: #eef0f6;
  --fg-dim: #b4b9c8;
  --ui-idle: 0.3;    /* arrows are almost invisible until hover/tap */
  --chip-idle: 0.55; /* text chips stay legible: "read more" is the only way to expand */
  --ui-live: 0.95;
  --scrim: rgba(5, 6, 10, 0.86);
  --gutter: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Vazirmatn", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body { overflow: hidden; overscroll-behavior: none; }

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  touch-action: pan-y; /* horizontal swipes belong to the day navigation */
}

#media { position: absolute; inset: 0; }
#media img,
#media iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
/* contain keeps the whole picture visible: astronomy images are often wide or tall. */
#media img { object-fit: contain; opacity: 0; transition: opacity 0.35s ease; }
#media img.ready { opacity: 1; }

#status {
  position: absolute;
  inset-inline: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  text-align: center;
  color: var(--fg-dim);
  font-size: 1.05rem;
  line-height: 1.8;
  pointer-events: none;
}

/* Arrows */
#nav {
  position: absolute;
  inset-inline: 0;
  top: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right));
  pointer-events: none;
}
.arrow {
  pointer-events: auto;
  width: 52px;
  height: 72px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--fg);
  opacity: var(--ui-idle);
  cursor: pointer;
  transition: opacity 0.25s ease, background 0.25s ease;
}
.arrow svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 3px #000); }
.arrow:hover, .arrow:focus-visible { opacity: var(--ui-live); background: rgba(5, 6, 10, 0.5); }
.arrow[disabled] { opacity: 0; pointer-events: none; }

/* Info panel over the bottom of the picture */
#info {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  max-height: 72vh;
  max-height: 72dvh;
  overflow-y: auto;
  padding: 56px max(var(--gutter), env(safe-area-inset-right)) max(var(--gutter), env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  /* The fade is a fixed band equal to the top padding, never a share of the height: a tall
     (expanded) panel would otherwise leave the title on a half-transparent background and
     the picture would show through the text. */
  background: linear-gradient(to top, var(--scrim) 0, var(--scrim) calc(100% - 56px), rgba(5, 6, 10, 0) 100%);
  /* On wide screens keep the text column readable and centred. */
  display: flex;
  flex-direction: column;
  align-items: center;
}
#info > * { width: 100%; max-width: 720px; }

.meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
#date { color: var(--fg-dim); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
#title { margin: 0 0 6px; font-size: clamp(1.15rem, 3.6vw, 1.6rem); font-weight: 700; line-height: 1.4; text-shadow: 0 1px 8px #000; }
#credit { margin: 0 0 8px; color: var(--fg-dim); font-size: 0.8rem; }

#explain {
  margin: 0;
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.98rem;
  line-height: 1.6;
  text-align: start;
  unicode-bidi: plaintext;
}
#explain.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chip {
  border: 1px solid rgba(238, 240, 246, 0.28);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.85rem;
  padding: 4px 14px;
  border-radius: 999px;
  cursor: pointer;
  opacity: var(--chip-idle);
  transition: opacity 0.25s ease, background 0.25s ease;
}
.chip:hover, .chip:focus-visible { opacity: var(--ui-live); background: rgba(238, 240, 246, 0.1); }
#more { margin-top: 8px; }

/* Tapping the picture reveals the controls for a few seconds on touch devices. */
#stage.ui-live .arrow:not([disabled]),
#stage.ui-live .chip { opacity: var(--ui-live); }

:focus-visible { outline: 2px solid #8ab4ff; outline-offset: 2px; }

@media (min-width: 900px) {
  #info { padding-top: 72px; }
  .arrow { width: 64px; height: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
