/* Shared components. All classes are prefixed .gtf- so they never collide with game stylesheets.
   Colour rules that compete with body.gtf a { } are written as body.gtf .x to win on specificity. */

/* ---------- Type ---------- */

.gtf-h1 {
  font-size: clamp(40px, 5.4vw, 66px);
  line-height: 1.03;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.gtf-h1--page {
  font-size: clamp(36px, 4.6vw, 56px);
}

.gtf-h2 {
  font-size: clamp(30px, 3.6vw, 44px);
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.gtf-h3 {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.gtf-lede {
  font-size: 19px;
  line-height: 1.55;
  color: var(--gtf-text-2);
  max-width: 34em;
}

.gtf-section--yellow .gtf-lede,
.gtf-section--teal .gtf-lede,
.gtf-section--pink .gtf-lede,
.gtf-card--yellow .gtf-lede {
  color: var(--gtf-ink);
}

.gtf-body {
  font-size: 17px;
  line-height: 1.55;
}

.gtf-muted {
  color: var(--gtf-text-2);
}

.gtf-eyebrow {
  font-family: var(--gtf-mono);
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gtf-text-3);
}

.gtf-mono {
  font-family: var(--gtf-mono);
}

.gtf-small {
  font-size: 14px;
}

/* ---------- Buttons ---------- */

/* Sizes follow the design: every button carries a 2px border (transparent when filled) and its
   padding is the design's padding minus that border, so filled and outlined buttons are the same size. */
.gtf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  border: 2px solid transparent;
  border-radius: var(--gtf-radius-btn);
  font-family: var(--gtf-font);
  font-size: 16px;
  font-weight: 800;
  line-height: normal;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, filter 0.15s;
  -webkit-appearance: none;
  appearance: none;

  &:disabled,
  &[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

body.gtf .gtf-btn--primary,
.gtf-btn--primary {
  background: var(--gtf-orange);
  color: var(--gtf-ink);
}

body.gtf .gtf-btn--primary:hover {
  background: var(--gtf-orange-hi);
  color: var(--gtf-ink);
}

body.gtf .gtf-btn--yellow,
.gtf-btn--yellow {
  background: var(--gtf-yellow);
  color: var(--gtf-ink);
}

body.gtf .gtf-btn--yellow:hover {
  background: var(--gtf-yellow-hi);
  color: var(--gtf-ink);
}

body.gtf .gtf-btn--dark,
.gtf-btn--dark {
  background: var(--gtf-ink);
  color: var(--gtf-cream);
}

body.gtf .gtf-btn--dark:hover {
  background: var(--gtf-ink-hover);
  color: var(--gtf-cream);
}

body.gtf .gtf-btn--surface,
.gtf-btn--surface {
  background: var(--gtf-surface-2);
  color: var(--gtf-cream);
}

body.gtf .gtf-btn--surface:hover {
  background: var(--gtf-surface-4);
  color: var(--gtf-cream);
}

body.gtf .gtf-btn--outline,
.gtf-btn--outline {
  background: transparent;
  border-color: var(--gtf-surface-4);
  color: var(--gtf-cream);
}

body.gtf .gtf-btn--outline:hover {
  border-color: var(--gtf-yellow);
  color: var(--gtf-cream);
}

/* Outline on a light (yellow/teal/pink) panel */
body.gtf .gtf-btn--outline-ink,
.gtf-btn--outline-ink {
  background: transparent;
  border-color: var(--gtf-ink);
  color: var(--gtf-ink);
}

body.gtf .gtf-btn--outline-ink:hover {
  background: rgba(28, 24, 20, 0.1);
  color: var(--gtf-ink);
}

body.gtf .gtf-btn--ghost,
.gtf-btn--ghost {
  background: transparent;
  color: var(--gtf-text-2);
  padding-left: 8px;
  padding-right: 8px;
}

body.gtf .gtf-btn--ghost:hover {
  color: var(--gtf-cream);
}

body.gtf .gtf-btn--danger,
.gtf-btn--danger {
  background: transparent;
  border-color: var(--gtf-surface-4);
  color: var(--gtf-orange-hi);
}

body.gtf .gtf-btn--danger:hover {
  border-color: var(--gtf-orange);
  background: rgba(238, 107, 47, 0.12);
  color: var(--gtf-orange-hi);
}

.gtf-btn--sm {
  padding: 7px 12px;
  font-size: 14px;
}

.gtf-btn--md {
  padding: 9px 16px;
  font-size: 15px;
}

.gtf-btn--lg {
  padding: 14px 26px;
  font-size: 17px;
}

/* Outlined and quiet buttons are one weight lighter than filled ones, as in the design. */
.gtf-btn--outline,
.gtf-btn--outline-ink,
.gtf-btn--danger,
.gtf-btn--surface,
.gtf-btn--ghost {
  font-weight: 700;
}

.gtf-btn--block {
  display: flex;
  width: 100%;
}

/* button_to wraps buttons in a form; keep them inline */
form.button_to {
  display: inline;
  margin: 0;
}

/* ---------- Cards ---------- */

.gtf-card {
  background: var(--gtf-surface-1);
  border-radius: var(--gtf-radius-card);
  padding: clamp(20px, 3vw, 32px);
  min-width: 0;
}

.gtf-card--raised { background: var(--gtf-surface-2); }

.gtf-card--outline {
  background: transparent;
  border: 2px solid var(--gtf-surface-4);
}

.gtf-card--sticker {
  border: 3px solid var(--gtf-yellow);
  box-shadow: var(--gtf-sticker);
}

.gtf-card--yellow {
  background: var(--gtf-yellow);
  color: var(--gtf-ink);
}

.gtf-card--game {
  background: var(--game-dark, var(--gtf-surface-1));
  box-shadow: inset 0 0 0 2px var(--game, transparent);
}

.gtf-card__title {
  margin-bottom: 8px;
}

/* ---------- Forms ---------- */

.gtf-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 440px;
}

.gtf-form--wide {
  max-width: 640px;
}

.gtf-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.gtf-label {
  font-family: var(--gtf-mono);
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gtf-text-3);
}

.gtf-input,
.gtf-textarea,
.gtf-select {
  width: 100%;
  background: var(--gtf-ink);
  border: 2px solid var(--gtf-surface-4);
  border-radius: var(--gtf-radius-input);
  padding: 13px 14px;
  color: var(--gtf-cream);
  font-family: var(--gtf-font);
  font-size: 16px;
  line-height: 1.4;
  transition: border-color 0.15s;

  &::placeholder {
    color: var(--gtf-line);
  }

  &:hover {
    border-color: var(--gtf-line);
  }

  &:focus {
    border-color: var(--gtf-yellow);
    outline: none;
  }

  &:focus-visible {
    outline: 3px solid color-mix(in oklch, var(--gtf-yellow) 45%, transparent);
    outline-offset: 1px;
  }
}

.gtf-input--raised,
.gtf-card .gtf-input,
.gtf-card .gtf-textarea,
.gtf-card .gtf-select {
  background: var(--gtf-ink);
}

.gtf-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--gtf-text-2) 50%), linear-gradient(135deg, var(--gtf-text-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.gtf-textarea {
  resize: vertical;
  min-height: 96px;
}

.gtf-input--code {
  font-family: var(--gtf-mono);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
}

.gtf-hint {
  font-size: 14px;
  color: var(--gtf-text-3);
}

.gtf-field--error {
  & .gtf-input,
  & .gtf-textarea,
  & .gtf-select {
    border-color: var(--gtf-orange);
  }

  & .gtf-label {
    color: var(--gtf-orange-hi);
  }
}

/* Rails wraps invalid fields in .field_with_errors; keep layout intact. */
.field_with_errors {
  display: contents;

  & .gtf-input,
  & .gtf-textarea,
  & .gtf-select {
    border-color: var(--gtf-orange);
  }
}

.gtf-form-errors {
  border: 2px solid var(--gtf-orange);
  border-radius: var(--gtf-radius-input);
  padding: 14px 16px;
  color: var(--gtf-cream);
  background: rgba(238, 107, 47, 0.1);

  & ul {
    margin: 6px 0 0 18px;
  }

  & li {
    font-size: 15px;
  }
}

.gtf-form-errors__title {
  font-weight: 800;
}

/* Honeypot: hidden from people and assistive tech */
.gtf-hp {
  position: absolute !important;
  left: -10000px !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- Pills (radio) and chips (checkbox) ---------- */

.gtf-pills,
.gtf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border: 0;
  padding: 0;
  margin: 0;
}

.gtf-pill,
.gtf-chip {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 11px 16px;
  border: 2px solid var(--gtf-surface-4);
  border-radius: var(--gtf-radius-btn);
  background: var(--gtf-ink);
  color: var(--gtf-cream);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;

  &:hover {
    border-color: var(--gtf-line);
  }

  & input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  &:has(input:focus-visible) {
    outline: 3px solid var(--gtf-yellow);
    outline-offset: 2px;
  }

  &:has(input:disabled) {
    opacity: 0.45;
    cursor: not-allowed;
  }
}

.gtf-pill:has(input:checked) {
  background: var(--gtf-orange);
  border-color: var(--gtf-orange);
  color: var(--gtf-ink);
}

.gtf-pill__sub {
  font-size: 13px;
  font-weight: 500;
  color: var(--gtf-text-2);
}

.gtf-pill:has(input:checked) .gtf-pill__sub {
  color: var(--gtf-ink);
}

.gtf-pill--dashed {
  border-style: dashed;
  border-color: var(--gtf-line);
}

.gtf-chip {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.gtf-chip__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  box-shadow: inset 0 0 0 2px var(--gtf-line);
}

.gtf-chip:has(input:checked) {
  border-color: var(--gtf-yellow);

  & .gtf-chip__dot {
    background: var(--gtf-yellow);
    box-shadow: inset 0 0 0 2px var(--gtf-yellow);
  }
}

/* ---------- Segmented control / tabs ---------- */

.gtf-seg {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border-radius: var(--gtf-radius-input);
  background: var(--gtf-surface-1);
}

.gtf-seg__tab {
  border: 0;
  border-radius: var(--gtf-radius-btn);
  padding: 10px 18px;
  background: transparent;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;

  body.gtf & {
    color: var(--gtf-text-2);
  }

  body.gtf &:hover {
    color: var(--gtf-cream);
  }

  body.gtf &[aria-selected="true"],
  body.gtf &.is-active {
    background: var(--gtf-orange);
    color: var(--gtf-ink);
  }
}

/* ---------- Stepper ---------- */

.gtf-stepper {
  display: inline-flex;
  align-items: center;
  gap: 10px;

  & input {
    width: 72px;
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    -moz-appearance: textfield;
  }

  & input::-webkit-outer-spin-button,
  & input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
}

.gtf-stepper__btn {
  width: 44px;
  height: 44px;
  border-radius: var(--gtf-radius-btn);
  border: 2px solid var(--gtf-surface-4);
  background: transparent;
  color: var(--gtf-cream);
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;

  &:hover {
    border-color: var(--gtf-yellow);
  }
}

/* ---------- Range ---------- */

.gtf-range {
  width: 100%;
  accent-color: var(--gtf-yellow);
}

.gtf-range-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--gtf-mono);
  font-size: 13px;
  color: var(--gtf-text-3);
}

.gtf-big-value {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* ---------- Disclosure ---------- */

.gtf-details {
  border-top: 2px solid var(--gtf-surface-3);
  padding-top: 14px;

  & > summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--gtf-text-2);
    list-style: none;
  }

  & > summary::-webkit-details-marker {
    display: none;
  }

  & > summary::before {
    content: "▸ ";
  }

  &[open] > summary::before {
    content: "▾ ";
  }

  & > summary:hover {
    color: var(--gtf-cream);
  }

  & > .gtf-details__body {
    margin-top: 16px;
  }
}

/* ---------- Code display ---------- */

.gtf-code {
  font-family: var(--gtf-mono);
  font-weight: 500;
  font-size: clamp(36px, 6vw, 56px);
  letter-spacing: 0.12em;
  line-height: 1;
  color: var(--gtf-yellow);
}

.gtf-qr {
  display: inline-block;
  padding: 12px;
  border-radius: var(--gtf-radius-btn);
  background: #fff;
  line-height: 0;

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

/* ---------- Status chips, badges ---------- */

.gtf-status {
  display: inline-block;
  flex: none;
  padding: 6px 14px;
  border-radius: var(--gtf-radius-btn);
  font-size: 14px;
  font-weight: 800;
  line-height: normal;
  background: var(--gtf-surface-4);
  color: var(--gtf-cream);
}

.gtf-status--waiting,
.gtf-status--lobby,
.gtf-status--setup {
  background: var(--gtf-yellow);
  color: var(--gtf-ink);
}

.gtf-status--active,
.gtf-status--playing,
.gtf-status--intermission,
.gtf-status--on_break {
  background: var(--gtf-success);
  color: var(--gtf-ink);
}

.gtf-status--finished,
.gtf-status--ended,
.gtf-status--complete {
  background: var(--gtf-surface-3);
  color: var(--gtf-text-2);
}

.gtf-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--gtf-radius-chip);
  font-family: var(--gtf-mono);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--gtf-surface-4);
  color: var(--gtf-cream);
}

.gtf-badge--soon {
  background: var(--gtf-pink);
  color: var(--gtf-ink);
}

.gtf-badge--night {
  background: var(--gtf-yellow);
  color: var(--gtf-ink);
}

/* ---------- Game icon ---------- */

.gtf-game-icon {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: var(--size, 44px);
  height: var(--size, 44px);
  border-radius: var(--gtf-radius-tile);
  background: var(--game, var(--gtf-surface-4));
  color: var(--gtf-ink);

  & svg {
    width: 58%;
    height: 58%;
  }
}

/* The snake glyph fills two thirds of the tile in the design (32 of 48px). */
.gtf-game-icon--snakes svg {
  width: 67%;
  height: 67%;
}

.gtf-game-icon--break {
  background: var(--gtf-surface-4);
  color: var(--gtf-cream);
}

/* ---------- Flash and toast ---------- */

.gtf-flash {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
  padding: 10px 10px 10px 16px;
  border: 2px solid var(--gtf-surface-4);
  border-radius: var(--gtf-radius-btn);
  background: var(--gtf-surface-1);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  transition: opacity 0.3s, transform 0.3s;

  &::before {
    content: "";
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gtf-success);
  }

  &.is-leaving {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.gtf-flash--alert {
  border-color: var(--gtf-orange);

  &::before {
    background: var(--gtf-orange);
  }
}

.gtf-flash__text {
  flex: 1;
}

.gtf-flash__close {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--gtf-radius-btn);
  background: transparent;
  color: var(--gtf-text-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;

  &:hover {
    background: var(--gtf-surface-3);
    color: var(--gtf-cream);
  }
}

.gtf-toast {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: var(--gtf-radius-input);
  background: var(--gtf-surface-2);
  border-left: 4px solid var(--gtf-teal);
  color: var(--gtf-cream);
  font-family: var(--gtf-font, system-ui, sans-serif);
  font-size: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);

  & span {
    flex: 1;
  }

  & button {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
  }
}

.gtf-toast--warning { border-left-color: var(--gtf-yellow); }
.gtf-toast--error { border-left-color: var(--gtf-orange); }

/* ---------- Empty state ---------- */

.gtf-empty {
  padding: 40px 24px;
  border: 2px dashed var(--gtf-surface-4);
  border-radius: var(--gtf-radius-card);
  text-align: center;
  color: var(--gtf-text-2);

  & .gtf-h3 {
    color: var(--gtf-cream);
    margin-bottom: 8px;
  }
}

/* ---------- Lists ---------- */

.gtf-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gtf-list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--gtf-radius-input);
  background: var(--gtf-surface-2);
  min-width: 0;
}

.gtf-list-row__main {
  flex: 1;
  min-width: 0;
}

.gtf-list-row__title {
  font-weight: 800;
  font-size: 17px;
}

.gtf-list-row__meta {
  font-size: 14px;
  color: var(--gtf-text-2);
}

/* ---------- Ticks list ---------- */

/* ---------- Steps ---------- */

.gtf-steps {
  font-family: var(--gtf-mono);
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gtf-text-3);
}

/* ---------- Pagination (pagy nav) ---------- */

.gtf-pagy nav.pagy,
nav.pagy.gtf-pagy {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  font-family: var(--gtf-mono);
  font-size: 14px;

  & a {
    display: inline-block;
    min-width: 36px;
    padding: 6px 10px;
    border-radius: var(--gtf-radius-btn);
    background: var(--gtf-surface-2);
    text-align: center;
    color: var(--gtf-cream);
  }

  & a:hover {
    background: var(--gtf-surface-4);
    color: var(--gtf-cream);
  }

  & a.current,
  & a[aria-current="page"] {
    background: var(--gtf-yellow);
    color: var(--gtf-ink);
  }

  & a[aria-disabled="true"],
  & a.gap {
    opacity: 0.5;
    pointer-events: none;
  }
}

/* ---------- Divider / danger zone ---------- */

.gtf-danger-zone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 2px solid var(--gtf-surface-3);
}

/* ---------- Avatar wrapper (keeps shared/_avatar output tidy) ---------- */

.gtf-avatar-wrap {
  flex: none;
  display: inline-flex;
}
