/* MURDOCH — shared styles.
   Layout: a balanced hive with two centres, MURDOCH and Contact, sitting in a faint comb of
   empty cells. home.js works out the shape and positions; this file only styles the cells. */

@font-face {
  font-family: "Chakra Petch";
  src: url("/assets/fonts/chakra-petch-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Chakra Petch";
  src: url("/assets/fonts/chakra-petch-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/assets/fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/assets/fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ground: #171b20;      /* blue-tinted charcoal */
  --cell: #1f252c;        /* service cell face */
  --cell-lift: #252d36;   /* face on hover */
  --rim: #343e4a;         /* cell edge */
  --core: #12304b;        /* MURDOCH centre, navy */
  --accent: #4a90c8;      /* steel blue */
  --core2: #1a2e42;       /* Contact centre */
  --accent2: #6aa6d6;     /* lighter steel blue */
  --text: #ece6d8;        /* cream */
  --muted: #9ba7b3;
  --faint: #7f8b97;
  --up: #5dbe8a;
  --down: #e8875f;
  --danger-rim: #6a4334;
  --danger-face: #1d1c1d;
  --ph-rim: #2b333d;
  --ph-face: #1a1f25;
  --ph-ink: #55616e;
  --ghost-rim: #232a33;

  --font-display: "Chakra Petch", "Bahnschrift", "DIN Alternate", "Segoe UI", sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;

  --hex: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  overflow-x: hidden;
}

a {
  color: var(--text);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Stage ---------- */

.stage {
  display: grid;
  place-items: center;
  padding-block: max(28px, env(safe-area-inset-top, 0px)) 12px;
  overflow: hidden;
  margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px))) calc(-1 * max(16px, env(safe-area-inset-right, 0px)));
}

.hive {
  --w: 132px;
  --bw: 2px;
  position: relative;
}

.cells {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cells li {
  display: contents;
}

/* Before home.js has laid the hive out (or if scripts are off) the cells wrap as a simple grid. */
.hive:not(.laid) .cells {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 760px;
  padding-inline: 16px;
}

.hive:not(.laid) .cell {
  position: relative;
  width: var(--w);
  height: calc(var(--w) * 1.1547);
}

/* Without scripts the status can't be checked, so don't promise it. */
.hive:not(.laid) .status {
  visibility: hidden;
}

.hive.laid .cells,
.hive.laid .comb {
  position: absolute;
  inset: 0;
}

.hive.laid .cell {
  position: absolute;
}

/* ---------- Cells ---------- */

.cell {
  --rim-colour: var(--rim);
  --face: var(--cell);
  display: block;
  background: var(--rim-colour);
  clip-path: var(--hex);
  text-decoration: none;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.face {
  position: absolute;
  inset: calc(var(--bw) * 1.1547) var(--bw);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--w) * 0.03);
  background: var(--face);
  clip-path: var(--hex);
  text-align: center;
  padding-inline: 11%;
}

.icon {
  width: clamp(18px, calc(var(--w) * 0.18), 30px);
  height: auto;
  aspect-ratio: 1;
  flex: none;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.2s ease;
}

.name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(11px, calc(var(--w) * 0.118), 18px);
  line-height: 1.15;
  letter-spacing: 0.01em;
}

.desc {
  margin: 0;
  font-size: clamp(11px, calc(var(--w) * 0.083), 13px);
  line-height: 1.3;
  color: var(--muted);
}

/* Service cells */
a.cell:hover {
  --rim-colour: var(--accent);
  --face: var(--cell-lift);
}

a.cell:focus {
  outline: none;
}

a.cell:focus-visible {
  --rim-colour: var(--text);
  --bw: 3px;
  --face: var(--cell-lift);
}

.svc[data-state="down"] .icon {
  opacity: 0.4;
}

.svc[data-state="down"] .desc {
  color: var(--down);
}

/* MURDOCH centre */
.core {
  --bw: 3px;
  --rim-colour: var(--accent);
  --face: var(--core);
}

.core .name {
  font-weight: 700;
  font-size: calc(var(--w) * 0.16);
  line-height: 1;
  letter-spacing: 0.05em;
}

.status {
  color: #c9d6e2;
  text-wrap: balance;
}

.status .dot {
  display: inline-block;
  width: 8px;
  height: 9px;
  margin-right: 6px;
  vertical-align: -0.05em;
  background: var(--faint);
  clip-path: var(--hex);
}

.status[data-state="up"] .dot { background: var(--up); }
.status[data-state="down"] .dot { background: var(--down); }

/* Contact centre */
.core2 {
  --bw: 3px;
  --rim-colour: var(--accent2);
  --face: var(--core2);
}

.core2 .icon {
  stroke: #8dbde3;
  width: clamp(20px, calc(var(--w) * 0.21), 34px);
}

.core2 .name {
  font-weight: 700;
  font-size: calc(var(--w) * 0.15);
  letter-spacing: 0.05em;
}

.core2 .desc {
  color: #c9d6e2;
}

a.core2:hover,
a.core:hover {
  --rim-colour: var(--text);
}

/* Don't press */
.danger {
  --rim-colour: var(--danger-rim);
  --face: var(--danger-face);
}

.danger .icon { stroke: var(--down); }
.danger .name { color: var(--down); }
.danger .desc { color: #b48a79; }

a.danger:hover {
  --rim-colour: var(--down);
  --face: #241f1e;
}

/* Placeholders: dim cells that keep the shape complete */
.ph {
  --rim-colour: var(--ph-rim);
  --face: var(--ph-face);
}

.ph .icon { stroke: var(--ph-ink); }
.ph .name {
  color: var(--faint);
  font-size: clamp(10px, calc(var(--w) * 0.098), 15px);
}
.ph .desc { color: #66727f; }

/* Empty comb cells behind the hive */
.ghost {
  --rim-colour: var(--ghost-rim);
  --face: var(--ground);
}

/* Narrow screens: names only, except the centres and anything offline */
.hive.compact .desc {
  display: none;
}

.hive.compact .core .desc,
.hive.compact .core2 .desc,
.hive.compact .svc[data-state="down"] .desc {
  display: block;
  font-size: 10px;
}

.hive.compact .face {
  padding-inline: 8%;
}

/* ---------- Footer ---------- */

.foot {
  padding-block: 4px max(18px, env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 13px;
  color: var(--faint);
}

.foot p {
  margin: 0;
}

/* ---------- The one motion moment: the hive settles on load ---------- */

@media (prefers-reduced-motion: no-preference) {
  .hive.laid .enter {
    animation: settle 0.45s cubic-bezier(0.2, 0.75, 0.25, 1) backwards;
  }

  a.cell,
  a.cell .face {
    transition: background-color 0.14s ease;
  }

  .status[data-state="checking"] .dot {
    animation: pulse 1.1s ease-in-out infinite alternate;
  }
}

@keyframes settle {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
}

@keyframes pulse {
  to {
    opacity: 0.3;
  }
}

/* ---------- Simple pages (404, video, events, contact) ---------- */

.simple {
  display: grid;
  place-items: center;
  padding-block: 48px;
  text-align: center;
}

.simple .wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 34ch;
}

.simple h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0.02em;
  text-wrap: balance;
}

.simple p {
  margin: 0;
  color: var(--muted);
}

.simple .back {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--accent);
  text-underline-offset: 3px;
}

.simple .back:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 4px;
  border-radius: 2px;
}

/* A single empty cell, used on simple pages */
.lone {
  --w: 120px;
  position: relative;
  width: var(--w);
  height: calc(var(--w) * 1.1547);
  background: var(--rim);
  clip-path: var(--hex);
  display: grid;
  place-items: center;
}

.lone::after {
  content: "";
  position: absolute;
  inset: calc(2px * 1.1547) 2px;
  background: var(--ground);
  clip-path: var(--hex);
}

.lone .icon {
  position: relative;
  z-index: 1;
  width: 40px;
  stroke: var(--faint);
}

/* Loading ring of six cells used on the video page */
.spinner {
  --s: 22px;
  position: relative;
  width: calc(var(--s) * 3.4);
  height: calc(var(--s) * 3.4);
}

.spinner span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--s);
  height: calc(var(--s) * 1.1547);
  margin: calc(var(--s) * -0.577) 0 0 calc(var(--s) * -0.5);
  background: var(--rim);
  clip-path: var(--hex);
}

.spinner span:nth-child(1) { transform: rotate(0deg)   translateY(calc(var(--s) * -1.15)) rotate(0deg); }
.spinner span:nth-child(2) { transform: rotate(60deg)  translateY(calc(var(--s) * -1.15)) rotate(-60deg); }
.spinner span:nth-child(3) { transform: rotate(120deg) translateY(calc(var(--s) * -1.15)) rotate(-120deg); }
.spinner span:nth-child(4) { transform: rotate(180deg) translateY(calc(var(--s) * -1.15)) rotate(-180deg); }
.spinner span:nth-child(5) { transform: rotate(240deg) translateY(calc(var(--s) * -1.15)) rotate(-240deg); }
.spinner span:nth-child(6) { transform: rotate(300deg) translateY(calc(var(--s) * -1.15)) rotate(-300deg); }

.spinner span:nth-child(1) { background: var(--accent); }

@media (prefers-reduced-motion: no-preference) {
  .spinner span {
    animation: light 1.2s linear infinite;
  }
  .spinner span:nth-child(1) { animation-delay: 0s; }
  .spinner span:nth-child(2) { animation-delay: 0.2s; }
  .spinner span:nth-child(3) { animation-delay: 0.4s; }
  .spinner span:nth-child(4) { animation-delay: 0.6s; }
  .spinner span:nth-child(5) { animation-delay: 0.8s; }
  .spinner span:nth-child(6) { animation-delay: 1s; }
}

@keyframes light {
  0%, 30% { background: var(--accent); }
  31%, 100% { background: var(--rim); }
}
