/*
 * Pirate Deck — homepage helm.
 * Loaded on the front page only, after responsive.css. Everything here is
 * scoped to .hero--helm, so no other template is affected.
 */

/* The accent is a registered colour so it can morph between segments. */
@property --helm-acc {
  syntax: "<color>";
  inherits: true;
  initial-value: #efb748;
}

.hero--helm {
  --helm-acc: #efb748;
  --helm-line: rgba(240, 236, 228, 0.1);
  --helm-line-strong: rgba(240, 236, 228, 0.2);
  --helm-mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --helm-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --helm-spring: cubic-bezier(0.3, 1.35, 0.4, 1);
  /* First grid row of the hero: the space kept free for the navigation. */
  --helm-nav: 92px;
  --helm-w: min(64svh, 620px, 84vw);
  --helm-gap: clamp(10px, 2.6svh, 36px);
  --helm-hole-r: 60px;
  /* The hero ends after its last row; a taller window shows the next section
     instead of an empty band under the wheel. */
  min-height: 0;
  grid-template-rows: var(--helm-nav) auto auto auto;
  transition: --helm-acc 0.7s var(--helm-ease);
}

.hero--helm .captains-log {
  grid-row: 4;
}

.helm-sprite {
  position: absolute;
}

/* ---------- Backdrop: the size of the live hero, the hole under the hub ---------- */

/* The bundled artwork keeps the scale it has on the plain hero: "cover" of
   one screen. It is only moved, so that its black hole lies under the centre
   of the wheel. Figures of the artwork (1536 x 1024, hole at 775.5 / 240,
   shadow radius 62.5) are those of gargantua-vfx.js; 1.012 is the zoom the
   backdrop already has. A custom hero image is left exactly where it was. */
.hero--helm-artwork {
  --helm-unit: max(100vw / 1536, 100svh / 1024);
  --helm-hole-y: calc(var(--helm-nav) + var(--helm-gap) + var(--helm-w) / 2);
  --helm-hole-r: calc(var(--helm-unit) * 63.25);
  --helm-shift-x: calc(var(--helm-unit) * -7.59);
  --helm-shift-y: calc(var(--helm-hole-y) - var(--helm-unit) * 242.88 + 0.6svh);
}

.hero--helm-artwork .hero__background,
.hero--helm-artwork .speed-field {
  inset: 0 0 auto;
  height: 100svh;
  translate: var(--helm-shift-x) var(--helm-shift-y);
}

/* Moved down, the picture no longer reaches the top of the hero, and a long
   hero outruns its lower edge: both ends fade instead of showing a line. */
.hero--helm-artwork .hero__background {
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 min(var(--helm-shift-y) * 0.5, 90px), #000 86%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 min(var(--helm-shift-y) * 0.5, 90px), #000 86%, transparent 100%);
}

/* ---------- Stage: wheel, headline bar, briefing bar ---------- */

.helm-stage {
  grid-row: 2;
  position: relative;
  z-index: 2;
  width: min(100% - 8vw, 1360px);
  margin-inline: auto;
  padding-top: var(--helm-gap);
  display: grid;
  justify-items: center;
  align-content: start;
}

.helm {
  position: relative;
  width: var(--helm-w);
  aspect-ratio: 1;
  transform: perspective(1100px) rotateX(var(--helm-rx, 0deg)) rotateY(var(--helm-ry, 0deg));
  will-change: transform;
}

.helm svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.helm__ticks {
  transform-origin: 0 0;
  stroke: rgba(240, 236, 228, 0.26);
  stroke-width: 1;
  animation: helm-spin 180s linear infinite;
}

.helm__ticks .is-long {
  stroke: var(--brass);
  stroke-width: 1.5;
}

.helm__band {
  fill: none;
  stroke: rgba(214, 154, 47, 0.2);
  stroke-width: 12;
}

.helm__hair {
  fill: none;
  stroke: rgba(214, 154, 47, 0.42);
  stroke-width: 1;
}

.helm__spoke {
  stroke: rgba(214, 154, 47, 0.5);
  stroke-width: 2;
}

.helm__handle {
  fill: #0b0b0c;
  stroke: rgba(214, 154, 47, 0.75);
  stroke-width: 1.25;
}

.helm__arc {
  fill: none;
  stroke: rgba(240, 236, 228, 0.2);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke 0.4s, stroke-width 0.4s;
}

.helm__arc.is-ext {
  stroke-dasharray: 2 7;
}

.helm__arc.is-active {
  stroke: var(--c);
  stroke-width: 4;
}

.helm__seg {
  color: rgba(240, 236, 228, 0.78);
  cursor: pointer;
  transition: transform 0.55s var(--helm-spring), filter 0.4s, color 0.3s;
}

/* Smoked glass: the hole and its disk stay faintly visible under the wedges. */
.helm__seg path {
  fill: rgba(7, 7, 8, 0.82);
  stroke: rgba(214, 154, 47, 0.46);
  stroke-width: 1.25;
  stroke-linejoin: round;
  transition: fill 0.35s, stroke 0.35s;
}

.helm__seg.is-alt path {
  fill: rgba(16, 15, 14, 0.84);
}

.helm__seg text {
  fill: currentColor;
  font: 400 15px "Bebas Neue", Impact, sans-serif;
  letter-spacing: 0.14em;
  text-anchor: middle;
  pointer-events: none;
}

.helm__seg use {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.helm__seg.is-active {
  color: #0a0a0a;
  transform: translate(var(--dx), var(--dy));
  filter: drop-shadow(0 0 22px color-mix(in srgb, var(--c) 62%, transparent));
}

.helm__seg.is-active path {
  fill: var(--c);
  stroke: var(--c);
}

.helm__hub {
  fill: #060607;
  stroke: rgba(214, 154, 47, 0.6);
  stroke-width: 1.25;
}

.helm__ring {
  fill: none;
  stroke: var(--helm-acc);
  stroke-width: 2;
  filter: drop-shadow(0 0 8px var(--helm-acc));
}

.helm__needle {
  fill: var(--helm-acc);
  transform-origin: 0 0;
  transition: transform 0.85s var(--helm-spring);
}

/* Headline bar. */
.helm-copy {
  width: 100%;
  margin-top: calc(var(--helm-gap) * 0.6);
  text-align: center;
}

.hero--helm .eyebrow {
  margin: 0;
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.8);
}

.hero--helm h1 {
  margin-top: 10px;
  font-size: clamp(48px, min(11.5vw, 9svh), 96px);
  text-shadow: 0 2px 34px rgba(0, 0, 0, 0.72);
}

.hero--helm h1 .is-acc {
  color: var(--helm-acc);
}

.helm-copy__lede {
  max-width: 62ch;
  margin: 14px auto 0;
  color: #d4cfc6;
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1.5;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.9);
}

/* Briefing bar: follows the selected segment. */
.helm-brief {
  position: relative;
  width: min(560px, 100%);
  margin: clamp(14px, 2vh, 22px) auto clamp(12px, 1.6vh, 18px);
  padding: 22px 24px 24px;
  border: 1px solid var(--helm-line-strong);
  border-left: 2px solid var(--helm-acc);
  background: linear-gradient(140deg, rgba(15, 15, 15, 0.9), rgba(9, 9, 9, 0.84));
  text-align: left;
}

.helm-brief__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-family: var(--helm-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.helm-brief__index b {
  color: var(--helm-acc);
  font-weight: 400;
}

.helm-brief__kind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--helm-acc);
}

.helm-brief__title {
  margin: 12px 0 0;
  color: var(--bone);
  font: 400 clamp(36px, 3.6vw, 52px) / 0.95 "Bebas Neue", Impact, sans-serif;
  letter-spacing: 0.04em;
}

.helm-brief__text {
  min-height: 3.2em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.6;
}

/* The bundled fonts are Latin-only: Polish text takes the system face as a
   whole, so a line never mixes two fonts glyph by glyph. */
.helm-brief__text:lang(pl) {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.helm-brief__meta {
  min-height: 30px;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.helm-chip {
  padding: 6px 10px;
  border: 1px solid var(--helm-line-strong);
  color: var(--muted);
  font-family: var(--helm-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.helm-brief__actions {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 22px;
}

.helm-brief__hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #6f6b64;
  font-family: var(--helm-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.helm-brief__hint kbd {
  min-width: 22px;
  height: 22px;
  padding-inline: 4px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--helm-line-strong);
  color: var(--muted);
  font: 400 11px var(--helm-mono);
}

.helm-cta {
  --cut: 10px;
  padding: 15px 22px 14px;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: #0a0a0a;
  background: var(--helm-acc);
  font: 400 19px / 1 "Bebas Neue", Impact, sans-serif;
  letter-spacing: 0.12em;
  text-decoration: none;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  transition: filter 0.3s;
}

.helm-cta:hover {
  filter: brightness(1.12);
}

.helm-cta:focus-visible,
.helm-tab:focus-visible {
  outline: 2px solid var(--bone);
  outline-offset: 3px;
}

.helm-icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.helm-cta .helm-icon {
  font-size: 18px;
  transition: translate 0.35s var(--helm-ease);
}

.helm-cta:hover .helm-icon {
  translate: 4px 0;
}

/* ---------- Index row: also the keyboard and no-pointer control ---------- */

.helm-index {
  grid-row: 3;
  position: relative;
  z-index: 3;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border-top: 1px solid var(--helm-line);
  background: rgba(5, 5, 5, 0.8);
  list-style: none;
}

.helm-tab {
  position: relative;
  height: 100%;
  padding: 15px 18px 17px;
  display: grid;
  align-content: start;
  gap: 3px;
  border-right: 1px solid var(--helm-line);
  color: var(--muted);
  text-decoration: none;
  transition: color 0.3s, background 0.4s;
}

.helm-index li:last-child .helm-tab {
  border-right: 0;
}

.helm-tab::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--c);
}

.helm-tab.is-active {
  color: var(--bone);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 11%, transparent), transparent 80%);
}

.helm-tab.is-active::before {
  width: 100%;
}

.helm-tab.is-active.is-auto::before {
  animation: helm-fill var(--helm-cycle, 5s) linear forwards;
}

.helm-tab__num {
  color: var(--c);
  font-family: var(--helm-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
}

.helm-tab__name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 400 clamp(20px, 1.7vw, 26px) / 1 "Bebas Neue", Impact, sans-serif;
  letter-spacing: 0.07em;
}

.helm-tab__name .helm-icon {
  font-size: 14px;
  opacity: 0.6;
}

.helm-tab__sub {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
}

@keyframes helm-spin {
  to {
    rotate: 360deg;
  }
}

@keyframes helm-fill {
  from {
    width: 0;
  }

  to {
    width: 100%;
  }
}

/* ---------- From tablet width up the briefing is a low console ---------- */

@media (min-width: 1001px) {
  .helm-brief {
    width: min(1060px, 100%);
    padding: 14px 22px 18px;
  }

  .helm-brief__body {
    display: grid;
    grid-template-columns: minmax(0, 250px) minmax(0, 1fr) auto;
    column-gap: 30px;
    align-items: center;
  }

  .helm-brief__title {
    grid-column: 1;
    grid-row: 1 / span 2;
    margin-top: 6px;
    font-size: clamp(34px, 3vw, 46px);
  }

  .helm-brief__text {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    min-height: 4.8em;
    margin-top: 8px;
  }

  .helm-brief__meta {
    grid-column: 2;
    grid-row: 2;
    margin-top: 8px;
  }

  .helm-brief__actions {
    grid-column: 3;
    grid-row: 1 / span 2;
    min-width: 236px;
    margin-top: 6px;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
  }
}

/* ---------- Wide but not tall: headline left, wheel, briefing right ----------
   A window of 1180px or more in height has room for everything under the
   wheel and keeps the stacked layout. */

@media (min-width: 1280px) and (max-height: 1179px) {
  .hero--helm {
    --helm-w: min(64svh, 620px, 44vw);
  }

  /* The row is exactly as tall as the wheel, so the side columns can never
     push the wheel off the black hole; they are centred on it instead. */
  .helm-stage {
    padding-bottom: var(--helm-gap);
    grid-template-columns: minmax(0, 1fr) var(--helm-w) minmax(0, 1fr);
    grid-template-rows: var(--helm-w);
    column-gap: 28px;
    align-items: center;
  }

  .helm {
    grid-column: 2;
    grid-row: 1;
  }

  /* The accretion disk runs between the headline and the lede, like a rule. */
  .helm-copy {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
    display: grid;
    grid-template-rows: 1fr calc(var(--helm-hole-r) * 1.25) 1fr;
    translate: 0 calc(var(--helm-hole-r) * 0.45);
    container-type: inline-size;
    text-align: left;
  }

  .helm-copy__headline {
    grid-row: 1;
    align-self: end;
  }

  .hero--helm .eyebrow {
    font-size: min(23px, 1.5vw, 5.3cqi);
    white-space: nowrap;
  }

  .hero--helm h1 {
    font-size: min(29.5cqi, 10svh, 104px);
  }

  .hero--helm h1 span {
    display: block;
  }

  .helm-copy__lede {
    grid-row: 3;
    align-self: start;
    margin: 0;
    font-size: 15.5px;
  }

  /* Every segment fills the same space, so the card does not jump on a
     change: one title line, four text lines, two rows of chips. */
  .helm-brief {
    grid-column: 3;
    grid-row: 1;
    width: 100%;
    margin: 0;
    padding: 20px 22px 22px;
    container-type: inline-size;
  }

  .helm-brief__body {
    display: block;
  }

  .helm-brief__title {
    margin-top: 12px;
    font-size: min(46px, 12.4cqi);
    white-space: nowrap;
  }

  .helm-brief__text {
    min-height: 6.4em;
    margin-top: 10px;
  }

  .helm-brief__meta {
    min-height: 68px;
    margin-top: 12px;
    align-content: flex-start;
  }

  .helm-brief__actions {
    min-width: 0;
    margin-top: 18px;
    flex-direction: row;
    align-items: center;
    gap: 14px 18px;
  }

  .helm-brief__hint {
    display: none;
  }
}

/* Short screens. */
@media (min-width: 1001px) and (max-height: 840px) {
  .helm-brief__meta {
    display: none;
  }

  .helm-brief__text {
    min-height: 3.2em;
    font-size: 14.5px;
  }

  .helm-copy__lede {
    font-size: 14.5px;
  }

  .helm-tab {
    padding: 10px 16px 12px;
  }
}

@media (min-width: 1280px) and (max-height: 840px) {
  .helm-brief {
    padding: 16px 20px 18px;
  }

  .helm-brief__text {
    min-height: 6.4em;
  }
}

@media (min-width: 1001px) and (max-height: 700px) {
  .helm-tab__sub {
    display: none;
  }
}

@media (max-width: 1000px) {
  .hero--helm {
    --helm-w: min(84vw, 50svh, 460px);
  }

  .helm-brief__hint {
    display: none;
  }

  .helm-index {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .helm-index li:nth-child(3n) .helm-tab {
    border-right: 0;
  }

  .helm-index li:nth-child(n + 4) .helm-tab {
    border-top: 1px solid var(--helm-line);
  }
}

/* The navigation row of the hero is lower from here down. */
@media (max-width: 920px) {
  .hero--helm {
    --helm-nav: 76px;
  }
}

/* The theme switches to the narrower crop of the artwork here. */
@media (max-width: 760px) {
  .hero--helm-artwork {
    --helm-unit: max(100vw / 768, 100svh / 1024);
  }

  .helm-stage {
    width: calc(100% - 32px);
  }
}

@media (max-width: 640px) {
  .helm__seg text {
    display: none;
  }

  .helm__seg use {
    translate: 0 12px;
  }

  .helm-brief {
    padding: 18px 18px 20px;
  }

  .helm-brief__text {
    min-height: 0;
  }

  .helm-index {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .helm-index li:nth-child(3n) .helm-tab {
    border-right: 1px solid var(--helm-line);
  }

  .helm-index li:nth-child(2n) .helm-tab {
    border-right: 0;
  }

  .helm-index li:nth-child(n + 3) .helm-tab {
    border-top: 1px solid var(--helm-line);
  }

  .helm-tab {
    padding: 14px 14px 16px;
  }

  .helm-tab__sub {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero--helm,
  .helm__seg,
  .helm__seg path,
  .helm__arc,
  .helm__needle,
  .helm-tab,
  .helm-cta .helm-icon {
    transition: none;
  }

  .helm__ticks,
  .helm-tab.is-active.is-auto::before {
    animation: none;
  }
}
