/*
 * TKFlight — self-hosted stylesheet.
 *
 * Design notes:
 * - Mobile first. Everything is a single readable column; the desktop layout is
 *   the same column, centred, not a second design.
 * - Tinkercademy salmon (#f05d57) and charcoal (#171718), sampled from the
 *   official icon at logos.tk.sg. Lighter salmon text keeps small labels legible
 *   on tinted surfaces. No third-party fonts, remote images or inline styles;
 *   safe under a same-origin Content-Security-Policy.
 * - Metadata is laid out in a wrapping grid rather than a horizontally clipped
 *   strip, so long branch names, bundle IDs and versions stay readable on a
 *   narrow phone without causing page-wide overflow.
 */

/* ---------------------------------------------------------------- tokens -- */

:root {
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #171718;
  --surface: #211f20;
  --surface-2: #292527;
  --surface-3: #30292b;

  --line: #41383b;
  --line-strong: #615255;

  --text: #fff4f1;
  --text-muted: #c0b5b7;
  --text-faint: #aa9da0;

  --accent: #f05d57;
  --accent-hover: #ff8076;
  --accent-text: #ff9b91;
  --accent-soft: rgba(240, 93, 87, 0.13);
  --accent-ink: #211314;
  --warn: #f0b866;
  --warn-soft: rgba(240, 184, 102, 0.08);
  --warn-line: rgba(240, 184, 102, 0.34);
  --focus: #ffc1b8;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-pill: 999px;

  --shell: 860px;
  --gutter: 16px;
}

/* ------------------------------------------------------------------ base -- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(95% 46% at 50% -6%, rgba(240, 93, 87, 0.09), transparent 62%),
    radial-gradient(58% 34% at 102% 4%, rgba(240, 93, 87, 0.04), transparent 60%);
  background-repeat: no-repeat;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  overflow-wrap: anywhere;
}

p {
  overflow-wrap: anywhere;
}

img {
  max-width: 100%;
}

code {
  font-family: var(--mono);
}

a {
  color: var(--accent-text);
  text-decoration-color: rgba(240, 93, 87, 0.42);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-color: currentColor;
}

button {
  font: inherit;
}

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

.icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.skip-link {
  position: absolute;
  top: 0;
  left: -9999px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 0 0 var(--r-sm) 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

/* ---------------------------------------------------------------- chrome -- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(23, 23, 24, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 10px var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand-mark {
  color: var(--accent);
  flex: none;
}

.brand-mark__plane {
  fill: currentColor;
}

.brand-mark__fold {
  fill: none;
  stroke: var(--bg);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.brand__name {
  font-size: 1.02rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.icon-button:hover {
  background: var(--surface-3);
  border-color: var(--line-strong);
}

.shell {
  max-width: var(--shell);
  min-width: 0;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.site-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: var(--shell);
  margin: 56px auto 0;
  padding: 24px var(--gutter) 48px;
  border-top: 1px solid var(--line);
}

.site-footer__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.site-footer__nav a {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-decoration: none;
}

.site-footer__nav a:hover {
  color: var(--text);
  text-decoration: underline;
}

.site-footer__note {
  max-width: 62ch;
  margin: 0;
  color: var(--text-faint);
  font-size: 0.82rem;
  line-height: 1.6;
}

/* -------------------------------------------------------------- controls -- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.button:hover {
  background: var(--surface-3);
}

.button:active {
  transform: translateY(1px);
}

.button--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.button--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.button--quiet {
  background: var(--surface);
}

.button--large {
  padding: 14px 30px;
  font-size: 1.05rem;
}

.button--small {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.button--block {
  width: 100%;
}

.chip {
  flex: none;
  margin-right: 14px;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chip--active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ------------------------------------------------------------------ hero -- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 0 26px;
  text-align: center;
}

.hero--compact {
  padding-top: 32px;
}

.hero__icon {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22.37%;
  background: linear-gradient(158deg, var(--surface-3), var(--bg));
  box-shadow: 0 20px 44px -26px #000, 0 0 0 1px rgba(240, 93, 87, 0.08);
}

.hero__icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-mark {
  width: 62%;
  height: 62%;
  color: var(--accent);
}

.app-mark__orbit {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-dasharray: 4 6;
  opacity: 0.4;
}

.app-mark__plane {
  fill: currentColor;
}

.app-mark__fold {
  fill: none;
  stroke: var(--bg);
  stroke-width: 2.6;
  stroke-linecap: round;
}

.hero__title {
  max-width: 22ch;
  margin: 0;
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.hero__version {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.hero__lead {
  max-width: 52ch;
  margin: 0;
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.hero__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hero__more {
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--accent-text);
  font-size: 0.9rem;
  cursor: pointer;
  text-underline-offset: 3px;
}

.hero__more:hover {
  text-decoration: underline;
}

.hero__blocked {
  margin: 0;
  padding: 11px 20px;
  border: 1px solid var(--warn-line);
  border-radius: var(--r-pill);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.9rem;
}

/* -------------------------------------------------------------- metadata -- */

.meta {
  display: grid;
  /*
   * Two columns on a phone, four from 640px up. The strip always carries eight
   * items so both layouts fill every row; a partly filled row would expose the
   * hairline background below as a stray block.
   */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 6px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--line);
}

.meta__item {
  min-width: 0;
  padding: 14px 16px;
  background: var(--surface);
}

.meta__label {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.meta__value {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  margin: 5px 0 0;
}

.meta__primary {
  font-size: 1.02rem;
  font-weight: 600;
}

/* Technical identifiers read better, and fit better, in the monospace face. */
.meta__primary--code {
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.5;
}

.meta__secondary {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* --------------------------------------------------------------- notices -- */

.notices {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

.notice {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.notice__icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.notice__title {
  margin: 0 0 6px;
  font-size: 1rem;
}

.notice__body {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.62;
}

/* -------------------------------------------------------------- sections -- */

.section {
  min-width: 0;
  margin-top: 36px;
}

.section__heading {
  margin: 0 0 14px;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
}

.section__heading--page {
  font-size: clamp(1.6rem, 5vw, 2.1rem);
}

.section__lead {
  max-width: 62ch;
  margin: 0 0 12px;
  color: var(--text-muted);
  line-height: 1.65;
}

.section__empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  color: var(--text-faint);
}

.section__more {
  margin: 12px 0 0;
}

/* ------------------------------------------------------------ preview rail */

.rail {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0 14px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.rail:focus-visible {
  outline-offset: 4px;
}

.rail__list {
  display: flex;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rail__item {
  flex: 0 0 min(58vw, 200px);
  scroll-snap-align: start;
}

.rail__frame {
  aspect-ratio: 9 / 19.5;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}

.rail__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

/* ------------------------------------------------------------ release notes */

.notes {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.notes__title {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.notes__body {
  margin: 0;
  line-height: 1.68;
  white-space: pre-wrap;
}

.notes__testing {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.notes__subheading {
  margin: 0 0 8px;
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- history */

.history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history__item {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}

.history__item--active {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.history__link {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
  min-width: 0;
  padding: 14px 16px;
  color: inherit;
  text-decoration: none;
}

.history__link:hover .history__label {
  color: var(--accent-text);
}

.history__link--static {
  color: var(--text-muted);
}

.history__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history__label {
  font-weight: 600;
}

.history__summary {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.history__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--text-faint);
  font-size: 0.82rem;
}

/* ------------------------------------------------------------------- copy -- */

.copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 10px;
  margin-top: 16px;
}

.copy__label {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--text-faint);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.copy__value {
  grid-column: 1;
  margin: 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.copy__status {
  grid-column: 1 / -1;
  min-height: 1.2em;
  margin: 0;
  color: var(--accent-text);
  font-size: 0.84rem;
}

/* ----------------------------------------------------------------- panels -- */

.panel {
  margin-top: 26px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.panel--centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 22px;
  text-align: center;
}

.panel__icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-muted);
}

.panel__heading {
  margin: 0;
  font-size: clamp(1.4rem, 5vw, 1.9rem);
}

.panel__app {
  margin: 0;
  color: var(--accent-text);
  font-weight: 600;
}

.panel__body {
  max-width: 48ch;
  margin: 0;
  color: var(--text-muted);
  line-height: 1.65;
}

.panel__body--muted {
  color: var(--text-faint);
  font-size: 0.88rem;
}

.panel__actions {
  margin: 8px 0 0;
}

/* ----------------------------------------------------------------- banner -- */

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--warn-line);
  border-radius: var(--r-lg);
  background: var(--warn-soft);
}

.banner__icon {
  display: inline-flex;
  color: var(--warn);
}

.banner__text {
  flex: 1;
  min-width: 14ch;
  margin: 0;
  font-size: 0.92rem;
}

/* ------------------------------------------------------------ home / docs -- */

.links {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.links__link {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.links__link:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.links__title {
  font-weight: 600;
}

.links__body {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.toc {
  margin-top: 16px;
}

.toc__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc__list a {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.toc__list a:hover {
  color: var(--text);
}

.bullets {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ----------------------------------------------------------------- dialog -- */

.dialog {
  position: fixed;
  inset: 0;
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  height: fit-content;
  margin: auto;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
}

/*
 * Chromium does not stop the page behind a modal <dialog> from scrolling, so a
 * wheel over the backdrop moved the content behind the sheet and lost the
 * reader's place. Locking the root keeps the page still.
 *
 * No scrollbar-gutter is reserved on purpose: platforms with overlay
 * scrollbars (macOS, iOS, headless Chromium) take no layout space for the bar,
 * so reserving a gutter would shift the page by ~15px instead of preventing a
 * shift. On platforms with classic scrollbars the content shifts by half a
 * scrollbar while the sheet is open, which is the lesser cost.
 */
html:has(dialog[open]) {
  overflow: hidden;
}

.dialog::backdrop {
  background: rgba(12, 10, 11, 0.74);
}

.dialog__panel {
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: 0 44px 84px -44px #000;
}

.dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.dialog__heading {
  min-width: 0;
}

.dialog__title {
  margin: 0;
  font-size: 1.15rem;
}

.dialog__subtitle {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.dialog__grid {
  display: grid;
  gap: 20px;
  padding: 20px;
}

.dialog__qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.qr {
  width: 100%;
  max-width: 240px;
  padding: 10px;
  border-radius: var(--r-md);
  background: #fff;
}

.qr__svg svg {
  display: block;
  width: 100%;
  height: auto;
}

.qr__unavailable {
  margin: 0;
  padding: 24px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  color: var(--text-faint);
  font-size: 0.85rem;
  text-align: center;
}

.dialog__hint {
  max-width: 30ch;
  margin: 0;
  color: var(--text-faint);
  font-size: 0.8rem;
  line-height: 1.55;
  text-align: center;
}

.dialog__details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dialog__warning {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--warn-line);
  border-radius: var(--r-md);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.88rem;
}

.dialog__truth {
  margin: 14px 0 0;
  padding-left: 12px;
  border-left: 2px solid var(--line-strong);
  color: var(--text-faint);
  font-size: 0.84rem;
  line-height: 1.6;
}

.dialog__open {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 16px 0 0;
}

.dialog__open-note {
  color: var(--text-faint);
  font-size: 0.8rem;
}

.dialog__footer {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.dialog__footer p {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.82rem;
  line-height: 1.55;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 18px 0 0;
  padding-left: 20px;
  color: var(--text-muted);
  line-height: 1.62;
}

.details {
  display: grid;
  /*
   * An explicit `minmax(0, 1fr)` track is load-bearing. With an implicit
   * `auto` track the column's minimum is the widest item's min-content size,
   * and an unbreakable identifier such as a bundle ID made every row wider
   * than the sheet instead of wrapping inside it.
   */
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  margin: 18px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--line);
}

.details__row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  padding: 10px 13px;
  background: var(--surface);
}

.details__row dt {
  color: var(--text-faint);
  font-size: 0.82rem;
}

.details__row dd {
  min-width: 0;
  margin: 0;
  font-size: 0.85rem;
  text-align: right;
  /* Caller-supplied identifiers and names must break rather than push the row
     past the sheet's width. */
  overflow-wrap: anywhere;
}

/* ----------------------------------------------------------- wider layout -- */

@media (min-width: 640px) {
  :root {
    --gutter: 24px;
  }

  .hero {
    padding: 56px 0 34px;
  }

  .hero__icon {
    width: 144px;
    height: 144px;
  }

  .notices {
    grid-template-columns: 1fr 1fr;
  }

  .rail__item {
    flex-basis: 200px;
  }

  .meta {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dialog__grid {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .panel--centered {
    padding: 52px 32px;
  }
}

@media (min-width: 900px) {
  .section {
    margin-top: 44px;
  }
}

/* -------------------------------------------------------------- a11y bits -- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
