/*
 * Ofotfjorden.no. Dark only: the photographs carry the colour and the interface stays
 * quiet. One accent, the aurora green of the favicon, marks what is live or selected.
 * No inline styles anywhere: the pages' Content-Security-Policy would block them.
 */

/* Fonts: self-hosted, SIL OFL 1.1 (assets/fonts/README.md). The ?v= is the font's own
   version, so nginx can cache the files for good. The Inter URL is also preloaded by
   templates/layout.php and must match View::FONT_PRELOAD. */
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-wght-normal.woff2?v=5.3.0") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader-latin-400-normal.woff2?v=5.3.0") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #06090e;
  --raised: #0f151e;
  --line: #1e2734;
  --fg: #e9edf2;
  --muted: #9ba6b5;
  --accent: #4fe3a1;
  --warn: #f3b760;
  --ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  /* Height of what surrounds the live image, the timelapse or an archive day: the header
     and the data line under it. LivePage::SIZES repeats the 11rem for the image's sizes
     attribute. */
  --chrome: 11rem;
}

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

[hidden] {
  display: none !important;
}

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 1rem/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  flex: 1;
}

img,
video {
  max-width: 100%;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
  border-radius: 2px;
}

.icon {
  flex: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  top: -5rem;
  left: var(--gutter);
  z-index: 10;
  padding: 0.6rem 1rem;
  border-radius: 0.25rem;
  background: var(--fg);
  color: var(--bg);
}

.skip:focus {
  top: 0.5rem;
}

/* --- Shell ----------------------------------------------------------------------- */

.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 1.5rem;
  min-height: 3.5rem;
  padding-inline: var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  justify-self: start;
  color: var(--fg);
  font: 400 1.375rem/1 var(--display);
  text-decoration: none;
}

/* Centring the boxes leaves the mark low: its ink (aurora to ground line) sits below the
   middle of its box, the name's capitals above the middle of theirs. Lift it so the two
   share a centre and the ground line rests on the baseline. */
.brand .icon {
  translate: 0 -0.19em;
}

.mark-aurora {
  stroke: var(--accent);
}

.site-nav {
  display: flex;
  gap: clamp(1.25rem, 3vw, 2.25rem);
}

.site-nav a {
  position: relative;
  padding-block: 0.875rem;
  color: var(--muted);
  font-size: 0.9375rem;
  text-decoration: none;
  transition: color 0.2s;
}

.site-nav a:hover,
.site-nav a[aria-current] {
  color: var(--fg);
}

.site-nav a[aria-current]::after {
  content: "";
  position: absolute;
  inset: auto 0 0.55rem;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
}

.lang {
  display: flex;
  align-items: center;
  justify-self: end;
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.lang-item + .lang-item::before {
  content: "/";
  margin-inline: 0.4rem;
  color: var(--muted);
  font-weight: 400;
  opacity: 0.5;
}

.lang a,
.lang [aria-current] {
  padding-block: 0.8rem;
  color: inherit;
  text-decoration: none;
}

.lang a:hover,
.lang [aria-current] {
  color: var(--fg);
}

@media (max-width: 44rem) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .site-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: space-between;
    border-top: 1px solid var(--line);
  }
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  margin-top: clamp(3rem, 8vw, 6rem);
  padding: 1.5rem var(--gutter) 2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer p {
  margin: 0;
}

.site-footer nav {
  display: flex;
  gap: 1.5rem;
}

.site-footer a {
  padding-block: 0.5rem;
  text-underline-offset: 0.2em;
}

.site-footer a:hover {
  color: var(--fg);
}

/* The running commit (Release.php), to check a deploy at a glance. */
.site-footer .release {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  opacity: 0.7;
}

/* --- Shared pieces ---------------------------------------------------------------- */

h1 {
  margin: 0 0 1rem;
  font: 400 clamp(2rem, 4vw, 2.75rem) / 1.12 var(--display);
  letter-spacing: -0.005em;
}

/* A round button on a photo. Its own dark backing keeps it readable on snow. */
.round-btn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(6 9 14 / 0.55);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s, opacity 0.3s;
}

.round-btn:hover {
  background: rgb(6 9 14 / 0.85);
}

.prose {
  width: 100%;
  max-width: 46rem;
  margin-inline: auto;
  padding: clamp(2rem, 6vw, 4rem) var(--gutter) 0;
}

.prose p {
  color: var(--muted);
}

.prose .lead {
  color: var(--fg);
  font-size: 1.1875rem;
  line-height: 1.55;
}

.prose a {
  text-underline-offset: 0.2em;
}

.prose h2 {
  margin: 2rem 0 0.75rem;
  font: 400 1.5rem/1.2 var(--display);
}

.prose .plain-list {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  color: var(--muted);
}

.prose .plain-list li + li {
  margin-top: 0.35rem;
}

/* The credit line on the usage page: one click selects all of it, ready to copy. */
.prose .credit-line {
  margin: 1rem 0 1.25rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--raised);
  color: var(--fg);
  font: 400 1.25rem/1.35 var(--display);
  user-select: all;
}

/* The privacy policy: when it was last changed, and paths in the text. */
.prose .doc-meta {
  margin-top: -0.25rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.prose code {
  padding: 0.1em 0.3em;
  border-radius: 3px;
  background: var(--raised);
  color: var(--fg);
  font: 0.875em/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.prose strong {
  color: var(--fg);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0 0.4em;
  border: 1px solid var(--muted);
  border-radius: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

.onward-list {
  display: grid;
  gap: 0.25rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

.onward-list a {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding-block: 0.5rem;
  font: 400 1.375rem/1.2 var(--display);
  text-decoration: none;
}

.onward-list a:hover {
  color: var(--accent);
}

/* A link on to another page, right under the paragraph that mentions it (contact page). */
.onward-list--after-text {
  margin-top: -0.25rem;
}

/* The address on the contact page, large enough to read and copy at a glance. */
.prose .contact-email {
  margin: 0.5rem 0 1rem;
  font: 400 clamp(1.5rem, 5vw, 2rem)/1.2 var(--display);
  overflow-wrap: anywhere;
}

/* --- Live, and the 24-hour timelapse and the archive laid out like it -------------- */

.stage {
  display: grid;
  justify-items: center;
}

/* The image (or the video) is as large as the screen allows: full width, unless the
   window's height is the limit; then it shrinks so the data line under it stays in view.
   The text below starts at its left edge, or at the page gutter when it is full width. */
.page-stage {
  --frame-w: min(100%, max(calc((100vh - var(--chrome)) * 16 / 9), 62%));
  --frame-inset: max(var(--gutter), calc((100% - var(--frame-w)) / 2));
}

@supports (height: 100dvh) {
  .page-stage {
    --frame-w: min(100%, max(calc((100dvh - var(--chrome)) * 16 / 9), 62%));
  }
}

.frame-wrap {
  position: relative;
  width: var(--frame-w);
}

.frame {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--raised);
  cursor: zoom-in;
}

.frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.7s ease;
}

.frame img.is-entering,
.lightbox img.is-entering {
  opacity: 0;
}

.stage-btn {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
}

/* A video (the timelapse, an archive day) in the place and at the size of the live image. */
.frame-video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: var(--raised);
}

.live-info,
.about,
.notes,
.browser {
  padding-inline: var(--frame-inset);
}

.live-info {
  padding-top: 1rem;
}

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 1.25rem;
  margin: 0;
}

.status-main {
  font-size: 1.0625rem;
}

.dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.6rem;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 0.12em;
}

.dot.is-new {
  animation: arrived 1.4s ease-out 1;
}

@keyframes arrived {
  from {
    box-shadow: 0 0 0 0 rgb(79 227 161 / 0.7);
  }

  to {
    box-shadow: 0 0 0 0.7rem rgb(79 227 161 / 0);
  }
}

.is-late .dot {
  background: var(--warn);
}

.status-next {
  color: var(--muted);
}

.status-late {
  color: var(--warn);
}

.status .badge {
  align-self: center;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2.25rem;
  margin: 0.9rem 0 0;
}

.facts dt {
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.facts dd {
  margin: 0.1rem 0 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 44rem) {
  .facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem 1rem;
  }
}

.about {
  display: grid;
  gap: 2rem 4rem;
  padding-top: clamp(2.5rem, 6vw, 4.5rem);
}

@media (min-width: 64rem) {
  .about {
    grid-template-columns: minmax(0, 24rem) minmax(0, 1fr);
    align-items: start;
  }
}

/* The page's heading, when the page has its h1 at the top (an archive date without a recording). */
.about h2 {
  margin: 0 0 1rem;
  font: 400 clamp(1.75rem, 3.5vw, 2.25rem) / 1.15 var(--display);
}

.about p {
  max-width: 34rem;
  margin: 0;
  color: var(--muted);
}

.about p + p {
  margin-top: 0.75rem;
}

/* Short texts at the foot of the Live page: what the camera shows through the year. */
.notes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 2rem clamp(1.5rem, 4vw, 3.5rem);
  padding-top: clamp(2.5rem, 6vw, 4.5rem);
}

.notes section {
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.notes h2 {
  margin: 0 0 0.6rem;
  font: 400 1.375rem/1.2 var(--display);
}

.notes p {
  max-width: 30rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.onward {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: 1rem;
  max-width: 64rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.onward a {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 0.375rem;
  background: var(--raised);
  color: #fff;
  text-decoration: none;
}

.onward img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s ease;
}

.onward a:hover img,
.onward a:focus-visible img {
  transform: scale(1.03);
}

/* The one gradient on the site: a scrim so the label reads on any photo. */
.onward-label {
  position: absolute;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 1rem;
  padding: 3.5rem 1.25rem 1.1rem;
  background: linear-gradient(to top, rgb(0 0 0 / 0.78), rgb(0 0 0 / 0));
}

.onward-label strong {
  grid-column: 1;
  font: 400 1.5rem/1.2 var(--display);
}

.onward-label span {
  grid-column: 1;
  color: rgb(255 255 255 / 0.84);
  font-size: 0.875rem;
}

.onward-label .icon {
  grid-row: 1 / span 2;
  grid-column: 2;
  transition: transform 0.3s ease;
}

.onward a:hover .icon {
  transform: translateX(0.25rem);
}

.onward a.no-image {
  aspect-ratio: auto;
  border: 1px solid var(--line);
}

.no-image .onward-label {
  position: static;
  padding: 1.25rem;
  background: none;
}

/* Full screen: the image alone on black. Pointer and button fade when nothing moves. */
.lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #000;
}

.lightbox::backdrop {
  background: #000;
}

/* The part that goes full screen (a dialog cannot); without the Fullscreen API it fills
   the dialog, which fills the window. */
.lightbox-view {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
}

.lightbox-view:fullscreen {
  width: 100vw;
  height: 100vh;
}

/* The image covers the screen, so a screen of another shape cuts some of it off. It starts
   with its bottom edge showing (the land; an ultrawide loses sky), and live.js lets it be
   dragged to show the rest (it sets --at). A new image fades in over the old one, as on
   the page. */
.lightbox img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--at, 50% 100%);
  transition: opacity 0.7s ease;
  cursor: zoom-out;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.lightbox.can-pan img {
  cursor: grab;
}

.lightbox.is-dragging img {
  cursor: grabbing;
}

/* Camera data at the bottom left; the time and ofotfjorden.no at the bottom right. */
.lightbox-caption {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 2.25rem;
  margin: 0;
  padding-block: 4rem max(1.25rem, env(safe-area-inset-bottom, 0px));
  padding-inline: max(1.5rem, env(safe-area-inset-left, 0px)) max(1.5rem, env(safe-area-inset-right, 0px));
  background: linear-gradient(to top, rgb(0 0 0 / 0.65), rgb(0 0 0 / 0.3) 55%, transparent);
  pointer-events: none;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.75), 0 0 1rem rgb(0 0 0 / 0.45);
}

/* The time, and under it ofotfjorden.no set to the same width: live.js measures the two
   and sets --brand-size. The size given here is close to that for Inter, until it has. */
.lightbox-stamp {
  display: grid;
  justify-items: end;
  margin: 0 0 0 auto;
}

.lightbox-stamp time {
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lightbox-brand {
  font-size: var(--brand-size, 1.75rem);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.lightbox-caption dl {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2.25rem;
  margin: 0;
}

.lightbox-caption dt {
  color: rgb(255 255 255 / 0.75);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.lightbox-caption dd {
  margin: 0.1rem 0 0;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lightbox-close {
  position: absolute;
  top: max(1rem, env(safe-area-inset-top, 0px));
  right: max(1rem, env(safe-area-inset-right, 0px));
}

.lightbox.is-idle,
.lightbox.is-idle img {
  cursor: none;
}

.lightbox.is-idle .lightbox-close:not(:focus-visible) {
  opacity: 0;
}

/* --- The archive: a day in the player, and under the text the browser ------------- */

/* The selected day's date, and at the other end the steps to the days around it. */
.day-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 2rem;
}

.day-title {
  font: 400 1.5rem/1.2 var(--display);
}

.js-clock-time {
  font-variant-numeric: tabular-nums;
}

.day-nav {
  display: flex;
  gap: 1.5rem;
}

.step {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding-block: 0.4rem;
  color: var(--muted);
  font-size: 0.9375rem;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s;
}

a.step:hover {
  color: var(--fg);
}

/* Something that can't be chosen: a day or a month without recordings, a step past the
   archive's first or last day. */
.is-off {
  opacity: 0.4;
}

.browser {
  padding-top: clamp(2.5rem, 6vw, 4rem);
  scroll-margin-top: 1rem;
  --day-gap: clamp(0.2rem, 0.6vw, 0.5rem);
}

/* The year row and the month row. The small number is the recordings in each. */
.pick ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pick-months ul {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  margin-top: 0.5rem;
}

.pick-item {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  color: var(--muted);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s, background-color 0.2s;
}

.pick-item small {
  font-size: 0.6875rem;
  opacity: 0.8;
}

a.pick-item:hover {
  background: var(--raised);
  color: var(--fg);
}

.pick-item[aria-current] {
  background: var(--raised);
  box-shadow: inset 0 -2px 0 var(--accent);
  color: var(--fg);
}

.month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.75rem 0 0.75rem;
}

.month-head h2 {
  margin: 0;
  font: 400 clamp(1.5rem, 3vw, 2rem) / 1.2 var(--display);
}

.month-steps {
  display: flex;
  gap: 0.5rem;
  margin: 0;
}

/* The round button, here on the page and not on a photo. */
.month-steps .round-btn {
  background: var(--raised);
  color: var(--fg);
}

.month-steps a.round-btn:hover {
  background: var(--line);
}

.month-steps .is-off {
  cursor: default;
}

/* The month: a week per row, Monday first. The spacing also goes round the table, so the
   margin pulls its edges back out to the edges of the video above. */
.month {
  width: calc(100% + 2 * var(--day-gap));
  margin: 0 calc(-1 * var(--day-gap));
  border-collapse: separate;
  border-spacing: var(--day-gap);
  table-layout: fixed;
}

.month th {
  padding: 0 0 0.15rem;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-align: left;
  text-transform: uppercase;
}

.month td {
  padding: 0;
}

/* A day is its picture, with the day of the month on a dark backing that reads on snow. */
.day {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 0.25rem;
  background: var(--raised);
  color: #fff;
  text-decoration: none;
}

.day img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s ease;
}

a.day:hover img,
a.day:focus-visible img {
  transform: scale(1.04);
}

.day-number {
  position: absolute;
  top: 0.3rem;
  left: 0.3rem;
  min-width: 1.7em;
  padding: 0 0.35em;
  border-radius: 0.2rem;
  background: rgb(6 9 14 / 0.6);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
  text-align: center;
}

.day.is-off {
  background: none;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--muted);
}

.day.is-off .day-number {
  background: none;
}

/* The day in the player: a frame drawn over the picture, and its number in the accent. */
.day[aria-current]::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--accent);
  border-radius: inherit;
}

.day[aria-current] .day-number {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

@media (max-width: 44rem) {
  /* Two tidy blocks: seven years to a row, six months, each with its number under it. */
  .pick-years ul {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .pick-months ul {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    margin-top: 0.75rem;
  }

  .pick-item {
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 0.4rem 0.1rem;
  }

  /* Seven pictures across a phone are small: square ones show more of each. */
  .day {
    aspect-ratio: 1;
  }

  .day-number {
    top: 0.15rem;
    left: 0.15rem;
    font-size: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
