/* Kora page (kora.html): the field-to-country network figure.
   Loaded after styles.css and content.css. Uses the site tokens only;
   every class is prefixed kn- so nothing leaks into other pages. */

/* The constellation's city labels would otherwise pop up over the figure. */
#fieldLabel {
  display: none;
}

.kn-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.kn-wrap {
  position: relative;
}

.kn-canvas {
  position: relative;
  z-index: 1;
  height: clamp(320px, 58vh, 620px);
  background: var(--bg); /* keeps the constellation field out of the figure */
  transition: background-color 0.4s var(--ease-out);
}

.kn-canvas canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: pan-y;
}

.kn-record {
  position: absolute;
  z-index: 2;
  top: clamp(0.8rem, 2vw, 1.2rem);
  right: clamp(1.5rem, 6vw, 8rem);
  padding: 0.7em 1.2em;
  background: var(--bg);
  color: var(--fg-dim);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border: 1px solid var(--hair);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease;
}

.kn-record:hover,
.kn-record:focus-visible {
  color: var(--accent-text);
  border-color: var(--accent-text);
  outline: none;
}

/* --- Stages: field, district, country --- */

.kn-stages {
  list-style: none;
  margin: 0;
  padding: 1.2rem clamp(1.5rem, 6vw, 8rem) 4vh;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.75rem, 3vw, 2.5rem);
}

.kn-stage-btn {
  position: relative;
  display: block;
  width: 100%;
  padding: 1.1rem 0 0;
  background: none;
  border: 0;
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

/* Hairline above each stage; the active one fills while the figure auto-advances. */
.kn-stage-btn::before,
.kn-stage-btn::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 2px;
}

.kn-stage-btn::before {
  width: 100%;
  background: var(--hair);
}

.kn-stage-btn::after {
  width: 0;
  background: var(--accent);
}

.kn-stage.is-active .kn-stage-btn::after {
  width: calc(var(--p, 1) * 100%);
}

.kn-idx {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--fg-dim);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transition: color 0.3s ease;
}

.kn-idx::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hair);
  transition: background-color 0.3s ease;
}

.kn-line {
  display: block;
  margin-top: 0.6rem;
  max-width: 30ch;
  color: var(--fg-faint);
  font-size: clamp(0.9rem, 1.3vw, 1rem);
  line-height: 1.45;
  transition: color 0.3s ease;
}

.kn-stage.is-active .kn-idx {
  color: var(--accent-text);
}

.kn-stage.is-active .kn-idx::before {
  background: var(--accent);
}

.kn-stage.is-active .kn-line,
.kn-stage-btn:hover .kn-line {
  color: var(--fg);
}

.kn-stage-btn:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 4px;
}

@media (max-width: 640px) {
  .kn-stages {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .kn-stage-btn {
    padding-bottom: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kn-canvas,
  .kn-idx,
  .kn-idx::before,
  .kn-line,
  .kn-record {
    transition: none;
  }
}

/* 3D layer (js/kora-3d.js). The flat canvas stays underneath as the fallback. */
.kn-canvas.kn-3d canvas:not(.kn-gl) {
  visibility: hidden;
}

.kn-gl {
  z-index: 1;
  cursor: grab;
}

.kn-gl:active {
  cursor: grabbing;
}

.kn-tag {
  position: absolute;
  z-index: 2;
  left: 0;
  top: 0;
  margin-top: -0.5em;
  font-family: var(--font);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--fg-faint);
  pointer-events: none;
  transition: color 0.4s ease;
}

.kn-tag.on {
  color: var(--accent-text);
}
