/* Ljod — the visual language of a graphical railway timetable.
   Hour rules running vertically, hairline gridwork, monospace clock times, and
   song titles set vertically inside their blocks the way station names run down
   a timetable column. */

:root {
  --blekk:    #0A0F12;  /* page ground */
  --panel:    #111A1F;
  --harstrek: #1C2A31;  /* hairlines */
  --tekst:    #DFE9E7;
  --dempa:    #7A8C8F;
  --signal:   #E8B54A;  /* the playhead, and nothing else */

  --sans:  'Familjen Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --mono:  'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;

  --rute-timar: 22px;
  --rute-merke: 18px;
  --rute-kropp: 260px;
  --gutt: clamp(16px, 4vw, 40px);
}

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

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

body {
  margin: 0;
  background: var(--blekk);
  color: var(--tekst);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  /* The rail is the only thing that scrolls sideways. */
  overflow-x: hidden;
}

a { color: inherit; text-decoration-color: var(--dempa); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--signal); }

:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

.skip {
  position: absolute; left: -9999px;
  background: var(--signal); color: var(--blekk);
  padding: 8px 14px; z-index: 100; border-radius: 2px;
}
.skip:focus { left: var(--gutt); top: 10px; }

/* ── Header ───────────────────────────────────────────────────────────────── */

.topp {
  border-bottom: 1px solid var(--harstrek);
  background: linear-gradient(180deg, var(--panel), var(--blekk));
}

.topp-inner {
  display: flex; flex-wrap: wrap; gap: 16px 24px;
  align-items: baseline; justify-content: space-between;
  padding: clamp(20px, 4vw, 34px) var(--gutt) 14px;
}

.merke { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
}

.undertittel {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(0.95rem, 2.6vw, 1.15rem);
  color: var(--dempa);
}

.no-spelar {
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--mono); font-size: 0.78rem;
  min-width: 0;
}

.no-merke {
  flex: none;
  text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.62rem;
  color: var(--dempa);
  border: 1px solid var(--harstrek);
  padding: 3px 7px; border-radius: 2px;
}
.no-merke.lever { color: var(--signal); border-color: var(--signal); }

.no-tekst {
  color: var(--tekst);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */

.faner { display: flex; gap: 0; padding: 0 var(--gutt); }

.fane {
  appearance: none; background: none; border: 0;
  border-bottom: 2px solid transparent;
  color: var(--dempa);
  font-family: var(--sans); font-size: 0.82rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 11px 2px; margin-right: 26px;
  cursor: pointer;
}
.fane:hover { color: var(--tekst); }
.fane[aria-selected="true"] { color: var(--tekst); border-bottom-color: var(--signal); }

/* ── Panels ───────────────────────────────────────────────────────────────── */

.panel { padding-block: clamp(22px, 4vw, 36px) 60px; }
.panel[hidden] { display: none; }

.panel-topp { padding-inline: var(--gutt); margin-bottom: 14px; }
.ordfelt-topp { margin-top: clamp(34px, 6vw, 56px); }

.panel-topp h2 {
  margin: 0;
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--dempa);
}

.prosa {
  margin: 5px 0 0;
  font-family: var(--serif); font-style: italic;
  font-size: clamp(1rem, 2.8vw, 1.22rem);
  color: var(--tekst);
  max-width: 46ch;
}

/* ── The rail ─────────────────────────────────────────────────────────────── */

.rute-ramme { position: relative; }

.rute-skrell {
  overflow-x: auto;
  overflow-y: hidden;
  border-block: 1px solid var(--harstrek);
  background: var(--panel);
  scrollbar-color: var(--harstrek) var(--panel);
}

.rute {
  position: relative;
  height: calc(var(--rute-timar) + var(--rute-merke) + var(--rute-kropp));
  min-width: 100%;
}

.rute-timar { position: absolute; inset-block-start: 0; height: var(--rute-timar); inset-inline-start: 0; right: 0; }
.rute-merke { position: absolute; top: var(--rute-timar); height: var(--rute-merke); left: 0; right: 0; }
.rute-kropp { position: absolute; top: calc(var(--rute-timar) + var(--rute-merke)); bottom: 0; left: 0; right: 0; }

/* Hour rules: a hairline the full height of the rail, labelled at the top. */
.time {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: var(--harstrek);
  pointer-events: none;
}
.time.dogn { background: #2A3D46; width: 2px; }

.time-merkelapp {
  position: absolute; top: 4px; left: 5px;
  font-family: var(--mono); font-size: 0.63rem; font-weight: 400;
  color: var(--dempa);
  white-space: nowrap;
}

/* A clock time only where a run of listening begins. On every block the scale
   turns to mush. */
.start-merkelapp {
  position: absolute; top: 1px;
  font-family: var(--mono); font-size: 0.66rem; font-weight: 500;
  color: var(--tekst);
  white-space: nowrap;
  padding-left: 4px;
  border-left: 1px solid var(--dempa);
  line-height: 1.2;
}

/* Silence, drawn rather than left out. */
.stille {
  position: absolute; top: 0; bottom: 0;
  border-left: 1px dashed #2E4049;
  border-right: 1px dashed #2E4049;
  pointer-events: none;
}
.stille-merkelapp {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--mono); font-size: 0.63rem;
  color: var(--dempa);
  white-space: nowrap;
  background: var(--panel);
  padding: 2px 6px;
}

/* ── Song blocks ──────────────────────────────────────────────────────────── */

.blokk {
  position: absolute; top: 0; bottom: 0;
  appearance: none; padding: 0; margin: 0;
  border: 0;
  border-left: 2px solid var(--farge);
  background: color-mix(in srgb, var(--farge) 20%, transparent);
  /* Without this a long title wraps into a second column and bleeds across the
     neighbouring blocks. */
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: background-color 120ms ease, opacity 120ms ease;
}

/* An INSET ring. The scroll container is overflow-y: hidden and a block fills
   the full height of the rail body, so the default 2px-outside ring is clipped
   top and bottom — a focus state you can only half see is not a focus state. */
.blokk:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: -2px;
}
.blokk:hover, .blokk:focus-visible {
  background: color-mix(in srgb, var(--farge) 42%, transparent);
}

/* A length we inferred rather than measured. The page never silently invents
   precision. */
.blokk.anslag {
  background-image: repeating-linear-gradient(
    135deg,
    color-mix(in srgb, var(--farge) 30%, transparent) 0 3px,
    transparent 3px 7px
  );
}

.blokk-tittel {
  display: block;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  white-space: nowrap;
  padding: 6px 0 6px 3px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--tekst);
  max-height: 100%;
}

.blokk-artist {
  display: block;
  writing-mode: vertical-rl;
  white-space: nowrap;
  padding-left: 3px;
  font-size: 0.62rem;
  color: var(--dempa);
}

/* Hover state: everything the hovered song did not touch steps back. */
.rute-kropp.fokusert .blokk { opacity: 0.28; }
.rute-kropp.fokusert .blokk.aktiv { opacity: 1; }

/* ── Playhead ─────────────────────────────────────────────────────────────── */

.naa {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--signal);
  pointer-events: none;
  z-index: 5;
}
.naa::after {
  content: '';
  position: absolute; top: -3px; left: -3px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--signal);
  animation: puls 2.4s ease-in-out infinite;
}
.naa-merkelapp {
  position: absolute; top: 3px; right: 6px;   /* anchored LEFT of the line, so
                                                 it cannot clip at the rail end */
  font-family: var(--mono); font-size: 0.62rem;
  letter-spacing: 0.12em;
  /* Deliberately NOT uppercased: "NO" reads as the English word, and this is the
     Nynorsk for "now". */
  color: var(--signal);
  white-space: nowrap;
}

@keyframes puls {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.7); }
}

.til-no {
  position: absolute; right: var(--gutt); bottom: 14px;
  appearance: none;
  background: var(--signal); color: var(--blekk);
  border: 0; border-radius: 2px;
  font-family: var(--mono); font-size: 0.7rem; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 7px 12px;
  cursor: pointer;
  z-index: 6;
}
.til-no[hidden] { display: none; }

/* ── Rail footer ──────────────────────────────────────────────────────────── */

.rute-foten {
  display: flex; flex-wrap: wrap; gap: 8px 22px;
  padding: 10px var(--gutt) 0;
  font-family: var(--mono); font-size: 0.66rem;
  color: var(--dempa);
}
.nokkel { display: inline-flex; align-items: center; gap: 7px; }

.prov { display: inline-block; width: 14px; height: 10px; flex: none; }
.prov-anslag {
  background-image: repeating-linear-gradient(135deg, var(--dempa) 0 2px, transparent 2px 5px);
  border-left: 2px solid var(--dempa);
}
.prov-naa { width: 2px; height: 12px; background: var(--signal); }

/* ── The word field ───────────────────────────────────────────────────────── */

.teljing {
  margin: 0 0 14px;
  padding-inline: var(--gutt);
  font-family: var(--mono); font-size: 0.72rem;
  color: var(--dempa);
}

.ordfelt {
  display: flex; flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  padding-inline: var(--gutt);
  min-height: 120px;
}

.ord {
  appearance: none; background: none; border: 0; padding: 0;
  font-family: var(--sans); font-weight: 500;
  line-height: 1.05;
  color: var(--farge);
  cursor: pointer;
  transition: opacity 140ms ease;
}
.ord sup {
  font-family: var(--mono);
  font-size: 0.42em; font-weight: 400;
  color: var(--dempa);
  margin-left: 2px;
  vertical-align: super;
}

.ordfelt.fokusert .ord { opacity: 0.16; }
.ordfelt.fokusert .ord.aktiv { opacity: 1; }

.ordfelt-tomt {
  font-family: var(--serif); font-style: italic;
  font-size: 1.05rem;
  color: var(--dempa);
  max-width: 44ch;
  flex-basis: 100%;
  margin: 0;
}

.ordfelt-hint {
  appearance: none; background: none;
  border: 1px solid var(--harstrek);
  border-radius: 2px;
  color: var(--tekst);
  font-family: var(--mono); font-size: 0.72rem;
  padding: 7px 12px;
  margin-top: 12px;
  cursor: pointer;
}
.ordfelt-hint:hover { border-color: var(--signal); color: var(--signal); }

/* ── Lista ────────────────────────────────────────────────────────────────── */

.totalar {
  display: flex; flex-wrap: wrap; gap: 10px 38px;
  padding-inline: var(--gutt);
  margin-bottom: 30px;
  font-family: var(--mono);
}
.total { display: flex; flex-direction: column; gap: 2px; }
.total b { font-size: 1.5rem; font-weight: 500; letter-spacing: -0.02em; }
.total span {
  font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--dempa);
}

.lister {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
  gap: 34px 40px;
  padding-inline: var(--gutt);
}

.liste-blokk h3 {
  margin: 0 0 10px;
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--dempa);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--harstrek);
}

table.liste { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
table.liste td { padding: 6px 0; border-bottom: 1px solid var(--harstrek); vertical-align: baseline; }
table.liste tr:last-child td { border-bottom: 0; }

td.plass {
  font-family: var(--mono); font-size: 0.7rem;
  color: var(--dempa);
  /* box-sizing is border-box, so the padding has to fit INSIDE this width —
     2.4em left the rank touching the title. */
  width: 3.6em; text-align: right; padding-right: 14px;
}
td.namn { line-height: 1.3; }
td.namn b { font-weight: 500; display: block; }
td.namn span { color: var(--dempa); font-size: 0.76rem; }
td.tal {
  font-family: var(--mono); font-size: 0.78rem;
  text-align: right; width: 4.5em;
  color: var(--tekst);
}

.liste-vert { color: var(--dempa); font-family: var(--mono); font-size: 0.74rem; }

/* ── Footer ───────────────────────────────────────────────────────────────── */

.foten {
  border-top: 1px solid var(--harstrek);
  padding: 22px var(--gutt) 40px;
  color: var(--dempa);
  font-size: 0.8rem;
  max-width: 62ch;
}
.foten p { margin: 0; }

/* ── Reduced motion ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .naa::after { animation: none; opacity: 1; }
}

/* ── Narrow ───────────────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  :root { --rute-kropp: 210px; }
  .topp-inner { flex-direction: column; align-items: flex-start; gap: 12px; }
  .no-spelar { max-width: 100%; }
  .til-no { right: 12px; }
}
