/*
 * The topic pages (web/templates/line.html, lines_home.html): the strip, the top bar, the panel
 * and the home cards. Colours, type, the header and the footer are in site.css, loaded first.
 * Design: docs/site-design.md.
 */

/* ---------- the scale stops, beside a topic page's title ---------- */
.scales {
  display: flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.scales button {
  padding: 6px 13px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 14px;
}
.scales button:hover { color: var(--text); }
.scales button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }

/* ---------- a topic's picture: a line drawing in one colour (web/topic_image.py), beside the topic's name ---------- */
/* --art, set on the page, is how wide the picture is for its height; the name beside it keeps clear of it */
.art { pointer-events: none; color: var(--muted); }
.art * { fill: none; stroke: currentColor; stroke-width: 1.2px; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.top-art, .card-art {
  position: absolute;
  opacity: 0.75;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}
/* on a topic page it stands between the title and the controls; on a phone, in the corner beside the title */
.top { position: relative; }
.top > :not(.art) { position: relative; }   /* the title and the controls stay in front */
.top-art { left: 50%; bottom: 12px; width: min(34%, calc(84px * var(--art))); height: 84px; transform: translateX(-50%); }

/* play, beside the scale stops: the line draws itself from its first day, or the lit story is walked through */
.controls { display: flex; align-items: center; gap: 10px; }
.play {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
}
.play[hidden] { display: none; }
.play:hover { border-color: var(--accent); }
.play svg { display: block; fill: currentColor; }
.play .play-stop, .play.on .play-go { display: none; }
.play.on { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.play.on .play-stop { display: inline; }

/* ---------- the top bar: the whole line, with a window on the part in view ---------- */
.mini-wrap { padding-top: 4px; }
#mini { display: block; width: 100%; cursor: pointer; touch-action: none; -webkit-user-select: none; user-select: none; }
#mini.sizing { cursor: ew-resize; }
.mini-main { fill: var(--line); }
.mini-branch { fill: none; stroke-width: 1.4; opacity: 0.9; }
.mini-window { fill: var(--tint); stroke: var(--accent); stroke-width: 1; cursor: grab; }
.mini-grip { fill: var(--accent); pointer-events: none; }
.mini-grab { fill: transparent; cursor: ew-resize; }
.mini-now { fill: var(--accent); }

/* ---------- the strip ---------- */
.strip-wrap {
  position: relative;
  max-width: 1080px;
  margin: 6px auto 0;
}
.strip {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  cursor: grab;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.strip::-webkit-scrollbar { display: none; }
.strip.dragging { cursor: grabbing; }
.strip:focus-visible { border-color: var(--accent); }
#line { display: block; }

.band { fill: var(--tint); }
.tick { stroke: var(--border); stroke-width: 1; }
.axis { fill: var(--muted); font-size: 11.5px; }

.main { fill: var(--line); }
.future { stroke: var(--faint); stroke-width: 3; stroke-dasharray: 2 7; stroke-linecap: round; }
.now { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 4; }
.now-label { fill: var(--accent); font-size: 11.5px; font-weight: 600; }
.main-hit { fill: none; stroke: transparent; stroke-width: 28; cursor: pointer; }

.branch { transition: opacity 0.15s; }
.branch-line { fill: none; stroke-width: 2.5; stroke-linecap: round; }
.branch-tail { stroke-width: 2.5; stroke-dasharray: 2 6; stroke-linecap: round; opacity: 0.7; }
.dot { stroke: var(--surface); stroke-width: 1.5; }
/* a branch's name, on top of every line: an edge in the strip's colour, so a line behind it does not cut through the letters, then the letters */
.branch-name { cursor: pointer; transition: opacity 0.15s; }
.branch-label, .branch-halo { font-size: 11.5px; font-weight: 600; letter-spacing: 0.3px; }
.branch-halo { fill: var(--surface); stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.branch-hit { fill: none; stroke: transparent; stroke-width: 20; cursor: pointer; }
.has-focus .branch:not(.focus), .has-focus .branch-name:not(.focus) { opacity: 0.16; }
.branch.focus .branch-line { stroke-width: 4; }
.has-focus .band { opacity: 0.45; }
.band-hover { fill: var(--tint); opacity: 0.55; pointer-events: none; }   /* under the mouse: the step a click would pick */
.ring { fill: none; stroke-width: 2; pointer-events: none; }

/* playing: the point the play has reached; "now" and the last-visit mark wait until it gets there */
.head { fill: var(--accent); stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.playing .now, .playing .now-label, .playing .future, .playing .visit, .playing .visit-label { opacity: 0; }
.arrived {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
  animation: arrived 0.9s ease-out forwards;
}
@keyframes arrived { from { transform: scale(1); opacity: 0.9; } to { transform: scale(4.5); opacity: 0; } }

/* since the last visit: a mark where the reader left off, and a glow behind each point that is new to them */
.visit { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 4; }
.visit-label { fill: var(--muted); font-size: 11.5px; }
.glow {
  opacity: 0.3;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
  animation: glow 2.6s ease-in-out infinite;
}
@keyframes glow { 50% { transform: scale(1.45); opacity: 0.12; } }
@media (prefers-reduced-motion: reduce) { .glow { animation: none; } }

/* under the strip: the first-visit hint or what the glow means, then how many stories are drawn and the switch for every one */
.under { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 18px; padding-top: 7px; font-size: 12.5px; }
.hint { color: var(--muted); transition: opacity 0.4s; }
.hint.gone { opacity: 0; }
.shown { margin-left: auto; color: var(--faint); }
.shown button { padding: 2px 0 2px 6px; border: 0; background: none; color: var(--accent); font-size: 12.5px; font-weight: 600; }
.shown button:hover { text-decoration: underline; }

/* the tip on a point of a branch: under the mouse on a laptop, after a tap on a phone */
.tip {
  position: absolute;
  z-index: 3;
  width: max-content;
  max-width: min(300px, calc(100% - 16px));
  padding: 10px 13px 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.4;
  pointer-events: none;
}
.tip.pinned { pointer-events: auto; border-color: var(--faint); }
.tip-story { display: flex; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 600; }
.tip-story .swatch { transform: translateY(-1px); }
.tip-when { margin-top: 1px; color: var(--muted); font-size: 12.5px; }
.tip-note { margin-top: 5px; }
.tip-more {
  margin-top: 9px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
.tip-more:hover { border-color: var(--accent); }

/* ---------- the panel ---------- */
.panel { padding-top: 22px; padding-bottom: 36px; }
.panel > * { max-width: 720px; }

.kicker { color: var(--accent); font-size: 14px; font-weight: 600; }
.range { color: var(--muted); font-size: 13px; }
.panel h2 { margin-top: 6px; font-size: 22px; line-height: 1.25; font-weight: 650; }
.summary { margin-top: 10px; color: var(--soft); }
.panel h3 {
  margin: 26px 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
}
.chip:hover { border-color: var(--faint); background: var(--surface-2); }

.articles li + li, .drill li + li { margin-top: 2px; }
.articles a {
  display: block;
  padding: 9px 12px;
  margin: 0 -12px;
  border-radius: 10px;
  text-decoration: none;
}
.articles a:hover { background: var(--surface); }
.publisher { display: block; color: var(--muted); font-size: 12.5px; }
.headline { display: block; }
.articles a:hover .headline { color: var(--accent); }

.drill button {
  display: flex;
  gap: 14px;
  width: calc(100% + 24px);
  margin: 0 -12px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: left;
}
.drill button:hover { background: var(--surface); }
.drill .when { flex: none; width: 104px; color: var(--muted); font-size: 14px; }
.drill .what { flex: 1; }

.back {
  margin-bottom: 14px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
}
.back:hover { color: var(--text); border-color: var(--faint); }
.story-name { padding-left: 12px; border-left: 4px solid var(--accent); }
.facts { margin-top: 8px; color: var(--muted); font-size: 14px; }

.entries { margin-top: 22px; border-left: 1px solid var(--border); }
.entries > li { position: relative; padding: 8px 12px 10px 18px; border-radius: 0 10px 10px 0; }
.entries > li + li { margin-top: 4px; }
.entries > li::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 16px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.entries > li { scroll-margin-top: 14px; }
/* the day whose point is open on the strip: tinted in the story's colour, and lit for a moment when Read more lands on it */
.entries > li.current { background: color-mix(in srgb, var(--dot, var(--accent)) 11%, transparent); }
.entries > li.current::before { left: -6px; top: 14px; width: 11px; height: 11px; background: var(--dot, var(--accent)); }
.entries > li.arrive { animation: arrive 1.6s ease-out; }
@keyframes arrive { from { background: color-mix(in srgb, var(--dot, var(--accent)) 46%, transparent); } }
.entries > li.current .when { color: var(--text); }
.entries .when { color: var(--muted); font-size: 13px; font-weight: 600; }
.entries .note { margin: 2px 0 4px; }

/* ---------- home ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  padding-top: 10px;
  padding-bottom: 30px;
}
.card {
  display: block;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card h2 { font-size: 21px; line-height: 1.2; font-weight: 650; }
.card-line { display: block; margin: 12px 0 10px; }
/* the topic's picture, in the corner beside its name: a wide one is held to under half the card */
.card { position: relative; }
.card-art { top: 14px; right: 16px; width: min(46%, calc(54px * var(--art))); height: 54px; }
.card.has-art .card-head { padding-right: calc(min(46%, 54px * var(--art)) + 26px); }
.card-head { position: relative; }
/* a card's line draws itself in when the page opens, each card a moment after the one before */
.card-line {
  clip-path: inset(0 100% 0 0);
  animation: draw-in 1.2s cubic-bezier(0.4, 0, 0.2, 1) calc(min(var(--i, 0), 5) * 0.12s) forwards;
}
@keyframes draw-in { to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) { .card-line { clip-path: none; animation: none; } }
.mini-visit { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.card-new {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--tint);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
}
.card-new[hidden] { display: none; }
.card-teaser { font-size: 17px; line-height: 1.35; }
.moving { margin-top: 12px; color: var(--muted); font-size: 14px; }
.moving li { display: flex; align-items: baseline; gap: 8px; }
.moving li + li { margin-top: 4px; }
.moving .swatch { transform: translateY(-1px); }
.moving .word { flex: none; color: var(--text); }

/* the way to the API, under the topics */
.api-pointer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  margin-bottom: 28px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
}
.api-pointer h2 { font-size: 16px; font-weight: 650; }
.api-pointer p { color: var(--muted); font-size: 14px; }

@media (max-width: 600px) {
  .top-art { left: auto; right: var(--gutter); bottom: auto; top: 16px; width: min(46%, calc(58px * var(--art))); height: 58px; transform: none; }
  .top.has-art .title { padding-right: calc(min(46%, 58px * var(--art)) + 18px); }
  .controls { width: 100%; }
  .scales { flex: 1; }
  .scales button { flex: 1; padding: 7px 0; }
  .drill button { flex-direction: column; gap: 0; }
  .drill .when { width: auto; font-size: 13px; }
}
