/* opelly.me — switchboard
   The page mirrors the architecture it describes: one origin on the left,
   patch cables fanning out to every hostname this box answers for. */

:root {
  --ink:      #150E24;
  --ink-lift: #1E1434;
  --line:     #35245A;
  --wire:     #553C86;
  --paper:    #EFE9F7;
  --dim:      #9C8FB8;
  --coral:    #FF6F5E;
  --mint:     #4FE0B5;
  --butter:   #FFC46B;

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body:    "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono:    "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --rail: 200px;
  --gutter: clamp(1.25rem, 5vw, 5rem);
}

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

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

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(120% 70% at 12% -10%, rgba(255,111,94,.14), transparent 60%),
    radial-gradient(90% 60% at 92% 8%, rgba(79,224,181,.09), transparent 65%);
  background-repeat: no-repeat;
}

/* ---------------------------------------------------------------- masthead */

.masthead {
  padding: clamp(3rem, 9vw, 7rem) var(--gutter) clamp(2rem, 5vw, 3.5rem);
  max-width: 1180px;
  margin: 0 auto;
}

.origin {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  margin: 0 0 clamp(1.5rem, 4vw, 2.5rem);
  padding: .3rem .75rem .3rem .4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.02);
}

.origin__label {
  font-family: var(--mono);
  font-size: .625rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--butter);
  border-radius: 999px;
  padding: .18rem .5rem;
}

.origin__ip {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--dim);
}

.masthead__title {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.6rem, 8.5vw, 6rem);
  line-height: .95;
  letter-spacing: -.035em;
  margin: 0 0 1.5rem;
  max-width: 15ch;
}

.masthead__title em {
  font-style: normal;
  color: var(--coral);
}

.masthead__lede {
  max-width: 46ch;
  margin: 0;
  color: var(--dim);
  font-size: clamp(1rem, 1.6vw, 1.1rem);
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  margin: clamp(2rem, 5vw, 3rem) 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.facts__item { margin: 0; }

.facts__key {
  font-family: var(--mono);
  font-size: .625rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 .3rem;
}

.facts__val {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.05rem;
}

/* ------------------------------------------------------------ switchboard */

.switchboard {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(3rem, 8vw, 6rem);
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
}

.cables {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.cables__wire {
  fill: none;
  stroke: var(--wire);
  stroke-width: 1.5;
  stroke-linecap: round;
  transition: stroke .25s ease, stroke-width .25s ease, opacity .25s ease;
}

.cables__wire.is-lit {
  stroke: var(--coral);
  stroke-width: 2.5;
}

.cables.is-focused .cables__wire:not(.is-lit) { opacity: .35; }

/* Trunk: the single origin every cable leaves from. */

.trunk {
  position: relative;
  grid-column: 1;
}

.trunk__node {
  position: absolute;
  top: var(--trunk-y, 50%);
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 6px rgba(255,111,94,.12), 0 0 26px rgba(255,111,94,.5);
}

.trunk__caption {
  position: absolute;
  top: var(--trunk-y, 50%);
  left: 50%;
  transform: translate(-50%, 18px);
  font-family: var(--mono);
  font-size: .625rem;
  letter-spacing: .1em;
  color: var(--dim);
}

/* ------------------------------------------------------------------ ports */

.ports {
  grid-column: 2;
  list-style: none;
  margin: 0;
  padding: 0;
}

.ports__empty {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--dim);
  padding: 2rem 0;
}

.port { border-top: 1px solid var(--line); }
.port:last-child { border-bottom: 1px solid var(--line); }

.port__link {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .2rem 1.5rem;
  padding: 1.4rem 0 1.5rem 1.75rem;
  text-decoration: none;
  color: inherit;
  transition: background-color .2s ease;
}

.port__link:hover,
.port__link:focus-visible {
  background: linear-gradient(90deg, rgba(255,111,94,.07), transparent 70%);
}

.port__link:focus-visible {
  outline: 2px solid var(--butter);
  outline-offset: -2px;
}

/* The jack sits on the border, where its cable lands. */
.port__jack {
  position: absolute;
  left: 0;
  top: 50%;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--ink);
  border: 1.5px solid var(--line);
  transition: border-color .2s ease, background-color .2s ease;
}

.port__link:hover .port__jack,
.port__link:focus-visible .port__jack {
  border-color: var(--coral);
  background: var(--coral);
}

.port__host {
  grid-column: 1;
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(1.15rem, 2.9vw, 1.85rem);
  letter-spacing: -.02em;
  line-height: 1.15;
  word-break: break-word;
  transition: color .2s ease;
}

.port__link:hover .port__host,
.port__link:focus-visible .port__host { color: var(--coral); }

.port__ident {
  grid-column: 1;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .55rem;
  margin-top: .15rem;
}

.port__name {
  font-family: var(--display);
  font-weight: 500;
  font-size: .95rem;
  color: var(--paper);
}

.port__tag {
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--butter);
  border: 1px solid rgba(255,196,107,.3);
  border-radius: 999px;
  padding: .1rem .45rem;
}

.port__blurb {
  grid-column: 1;
  margin: .5rem 0 0;
  max-width: 58ch;
  color: var(--dim);
  font-size: .92rem;
}

/* Status sits in its own column, right-aligned, monospaced so the numbers
   line up down the board like a real readout. */
.port__status {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
  gap: .5rem;
  align-self: start;
  padding-top: .35rem;
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--dim);
  white-space: nowrap;
}

.port__lamp {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dim);
  flex: none;
}

.port__status.is-up .port__lamp {
  background: var(--mint);
  box-shadow: 0 0 10px rgba(79,224,181,.7);
}

.port__status.is-down .port__lamp {
  background: var(--coral);
  box-shadow: 0 0 10px rgba(255,111,94,.7);
}

.port__status.is-down .port__latency { color: var(--coral); }

/* --------------------------------------------------------------- colophon */

.colophon {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem var(--gutter) clamp(3rem, 7vw, 5rem);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: baseline;
  justify-content: space-between;
}

.colophon__line {
  margin: 0;
  max-width: 60ch;
  color: var(--dim);
  font-size: .85rem;
}

.colophon__sig {
  margin: 0;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--line);
}

/* ------------------------------------------------------------- entry anim */

/* `backwards` fill holds the start frame during the delay, then hands the
   element back to its natural state. The rows are therefore visible if the
   animation never runs at all — the page's job is linking out, so content
   must never depend on an effect to appear. */

.port { animation: rise .5s ease backwards; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.cables__wire {
  stroke-dasharray: var(--len);
  animation: patch .8s ease backwards;
}

@keyframes patch {
  from { stroke-dashoffset: var(--len); }
  to   { stroke-dashoffset: 0; }
}

/* ---------------------------------------------------------------- responsive */

/* On wide screens the left rail is reserved for the cable run all the way
   down the page, so the masthead lines up with the hostname column. */
@media (min-width: 861px) {
  .masthead,
  .colophon { padding-left: calc(var(--gutter) + var(--rail)); }
}

@media (max-width: 860px) {
  .switchboard { grid-template-columns: minmax(0, 1fr); }
  .cables, .trunk { display: none; }
  .ports { grid-column: 1; }
  .port__link { padding-left: 0; padding-right: 0; }
  .port__jack { display: none; }
  .port__link { grid-template-columns: minmax(0, 1fr); }
  .port__status { grid-column: 1; grid-row: auto; padding-top: .75rem; }
  .port__link:hover, .port__link:focus-visible { background: none; }
}

@media (prefers-reduced-motion: reduce) {
  .port { animation: none; }
  .cables__wire { stroke-dasharray: none; animation: none; }
  * { transition-duration: .01ms !important; }
}
