/* --------------------------------------------------------------------------
   TbsRace shared components: buttons, cards, forms, stats, states and levels.
   -------------------------------------------------------------------------- */

.eyebrow {
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  line-height: 1.4;
  text-transform: uppercase;
}

.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.015), transparent 55%),
    var(--card);
  box-shadow: var(--shadow-soft);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.section-head h2 {
  margin-top: 4px;
  font-size: 1.18rem;
}

.section-meta {
  flex: none;
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  color: var(--gold);
  font-size: 0.77rem;
  font-weight: 500;
  transition: color 160ms var(--ease);
}

.text-link span {
  transition: transform 160ms var(--ease);
}

.text-link:hover {
  color: var(--gold-bright);
}

.text-link:hover span {
  transform: translateX(3px);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 11px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition:
    background-color 170ms var(--ease),
    border-color 170ms var(--ease),
    color 170ms var(--ease),
    transform 170ms var(--ease),
    box-shadow 170ms var(--ease);
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.btn-gold {
  background: var(--gold);
  color: #171204;
  box-shadow: 0 10px 26px rgba(216, 180, 74, 0.16);
}

.btn-gold:hover:not(:disabled) {
  background: var(--gold-bright);
  box-shadow: 0 12px 30px rgba(216, 180, 74, 0.24);
}

.btn-outline {
  border-color: var(--line-strong);
  background: rgba(244, 237, 225, 0.025);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--line-gold);
  background: var(--gold-wash);
  color: var(--gold-bright);
}

.btn-block {
  width: 100%;
}

.btn-small {
  min-height: 44px;
  padding: 8px 14px;
  font-size: 0.75rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(244, 237, 225, 0.03);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.3rem;
  line-height: 1;
  transition:
    border-color 160ms var(--ease),
    background-color 160ms var(--ease),
    color 160ms var(--ease);
}

.icon-button:hover {
  border-color: var(--line-gold);
  background: var(--gold-wash);
  color: var(--gold-bright);
}

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

.field {
  display: grid;
  gap: 7px;
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.field-label {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
}

.field-link {
  display: inline-block;
  margin-block: -13px;
  padding-block: 13px;
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 500;
}

.field-link:hover {
  color: var(--gold-bright);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  outline: none;
  background: rgba(7, 7, 6, 0.55);
  color: var(--text);
  font-size: 0.94rem;
  transition:
    border-color 160ms var(--ease),
    box-shadow 160ms var(--ease),
    background-color 160ms var(--ease);
}

.field input::placeholder {
  color: var(--muted-2);
}

.field input:hover {
  border-color: rgba(244, 237, 225, 0.25);
}

.field input:focus {
  border-color: var(--gold);
  background: rgba(7, 7, 6, 0.7);
  box-shadow: 0 0 0 3px rgba(216, 180, 74, 0.12);
}

.field input[readonly] {
  color: var(--muted);
  cursor: default;
}

.field input[aria-invalid="true"] {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(255, 125, 103, 0.1);
}

.field-hint {
  color: var(--muted-2);
  font-size: 0.74rem;
  line-height: 1.45;
}

.field-error {
  color: var(--coral);
  font-size: 0.76rem;
  line-height: 1.4;
}

.input-with-action {
  position: relative;
}

.input-with-action input {
  padding-right: 72px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  min-width: 54px;
  min-height: 44px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 600;
  transform: translateY(-50%);
}

.password-toggle:hover {
  background: var(--gold-wash);
}

.form-message {
  padding: 11px 13px;
  border: 1px solid rgba(255, 125, 103, 0.32);
  border-radius: var(--radius-xs);
  background: var(--coral-wash);
  color: #ffb3a7;
  font-size: 0.82rem;
  line-height: 1.45;
}

.form-message[data-tone="success"] {
  border-color: rgba(62, 209, 155, 0.3);
  background: var(--green-wash);
  color: #9defcd;
}

.form-message[data-tone="info"] {
  border-color: var(--line-strong);
  background: rgba(244, 237, 225, 0.04);
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Stat cards
   -------------------------------------------------------------------------- */

.stat-card {
  --stat-color: var(--gold);
  position: relative;
  overflow: hidden;
  min-width: 0;
  padding: 16px 16px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.02), transparent 60%),
    var(--card);
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--stat-color);
}

.stat-gold {
  --stat-color: var(--gold);
}

.stat-green {
  --stat-color: var(--green);
}

.stat-blue {
  --stat-color: var(--blue);
}

.stat-coral {
  --stat-color: var(--coral);
}

.stat-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-value {
  margin-top: 5px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2.2vw, 1.55rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Session rows and subject dots
   -------------------------------------------------------------------------- */

.subject-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--dot, var(--gold));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot, var(--gold)) 13%, transparent);
}

.session-list {
  display: grid;
}

.session-list-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.session-list-item:first-child {
  border-top: 0;
}

.session-list-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.session-subject {
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-time {
  flex: none;
  color: var(--muted-2);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.session-duration {
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Progress and levels
   -------------------------------------------------------------------------- */

.progress {
  overflow: hidden;
  height: 7px;
  border-radius: 999px;
  background: rgba(244, 237, 225, 0.08);
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
  transition: width 500ms var(--ease);
}

.level-card {
  padding: clamp(18px, 3vw, 24px);
}

.level-card-top {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 18px;
}

.level-medallion {
  position: relative;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--pct, 0) * 1%), rgba(244, 237, 225, 0.09) 0);
}

.level-medallion::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: inherit;
  background: var(--card);
}

.level-medallion span {
  position: relative;
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}

.level-card-copy {
  min-width: 0;
}

.level-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.level-title-row h3 {
  font-size: 1.22rem;
}

.level-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid var(--line-gold);
  border-radius: 999px;
  background: var(--gold-wash);
  color: var(--gold-bright);
  font-size: 0.63rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.level-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.4;
}

.level-progress {
  height: 8px;
  margin-top: 17px;
}

.level-bonus {
  margin-top: 9px;
  color: var(--muted-2);
  font-size: 0.69rem;
}

.level-hero {
  overflow: hidden;
  padding: clamp(22px, 4vw, 42px);
  background:
    radial-gradient(700px 380px at 82% 10%, rgba(216, 180, 74, 0.11), transparent 68%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.018), transparent 55%),
    var(--card);
}

.level-hero-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  text-align: center;
}

.level-orbit {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(170px, 28vw, 220px);
  aspect-ratio: 1;
  flex: none;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(216, 180, 74, 0.1), transparent 68%),
    conic-gradient(var(--gold) calc(var(--pct, 0) * 1%), rgba(244, 237, 225, 0.07) 0);
  box-shadow: 0 0 60px rgba(216, 180, 74, 0.09);
}

.level-orbit::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: inherit;
  background: var(--card);
}

.level-orbit-inner {
  position: relative;
  display: grid;
  justify-items: center;
}

.level-orbit-number {
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: clamp(3rem, 7vw, 4.2rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.level-orbit-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.level-hero-copy {
  width: 100%;
  max-width: 560px;
}

.level-hero-copy h2 {
  margin-top: 5px;
  font-size: clamp(2rem, 4.5vw, 3rem);
}

.level-hero-meta {
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.88rem;
}

.level-hero-progress {
  height: 8px;
  margin-top: 22px;
}

@media (min-width: 760px) {
  .level-hero-main {
    flex-direction: row;
    align-items: center;
    text-align: left;
  }

  .level-hero-copy {
    flex: 1;
  }
}

/* --------------------------------------------------------------------------
   Chips and pills
   -------------------------------------------------------------------------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 7px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(244, 237, 225, 0.025);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  transition:
    border-color 160ms var(--ease),
    background-color 160ms var(--ease),
    color 160ms var(--ease);
}

.chip:hover:not(:disabled) {
  border-color: var(--line-gold);
  color: var(--text);
}

.chip.is-selected {
  border-color: var(--line-gold);
  background: var(--gold-wash);
  color: var(--gold-bright);
}

.chip:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* --------------------------------------------------------------------------
   Alerts, notices and states
   -------------------------------------------------------------------------- */

.inline-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding: 11px 14px;
  border: 1px solid rgba(255, 125, 103, 0.28);
  border-radius: var(--radius-xs);
  background: var(--coral-wash);
  color: #ffc0b6;
  font-size: 0.8rem;
  line-height: 1.45;
}

.inline-alert-info {
  border-color: var(--line-gold);
  background: var(--gold-wash);
  color: #e9d99f;
}

.inline-alert .btn {
  flex: none;
}

.setup-notice {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  max-width: 640px;
  margin: clamp(32px, 8vh, 90px) auto;
  padding: clamp(22px, 4vw, 34px);
}

.setup-notice-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border: 1px solid var(--line-gold);
  border-radius: 50%;
  background: var(--gold-wash);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
}

.setup-notice h1 {
  margin-bottom: 10px;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
}

.setup-notice p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.setup-notice code {
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(244, 237, 225, 0.08);
  color: var(--gold-bright);
  font-size: 0.82em;
}

.error-state,
.empty-state {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 34px 18px;
  text-align: center;
}

.error-state-icon,
.empty-state-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 5px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(244, 237, 225, 0.035);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 1rem;
}

.error-state-icon {
  border-color: rgba(255, 125, 103, 0.3);
  background: var(--coral-wash);
  color: var(--coral);
}

.error-state h2,
.error-state h3,
.empty-state h3 {
  font-size: 1.05rem;
}

.error-state p,
.empty-state p {
  max-width: 360px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.error-state .btn {
  margin-top: 12px;
}

.error-card {
  margin-bottom: 20px;
}

.detail-empty {
  padding: 20px 6px;
  color: var(--muted-2);
  font-size: 0.82rem;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Skeleton loading
   -------------------------------------------------------------------------- */

.skeleton-stack {
  display: grid;
  gap: 9px;
}

.skeleton-line,
.skeleton-dot {
  display: block;
  overflow: hidden;
  height: 11px;
  border-radius: 999px;
  background: rgba(244, 237, 225, 0.07);
  animation: skeleton-pulse 1.6s ease-in-out infinite;
}

.skeleton-line-wide {
  width: 78%;
}

.skeleton-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.skeleton-line-name {
  width: min(52%, 220px);
}

.skeleton-line-chip {
  width: 48px;
}

.skeleton-line-time {
  width: 54px;
  justify-self: end;
}

@keyframes skeleton-pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 0.9;
  }
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast-region {
  position: fixed;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: 150;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.toast {
  max-width: 460px;
  padding: 12px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #1c1913;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: center;
  animation: toast-in 220ms var(--ease);
}

.toast-success {
  border-color: rgba(62, 209, 155, 0.35);
  color: #b8f3db;
}

.toast-error {
  border-color: rgba(255, 125, 103, 0.38);
  color: #ffc0b6;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 200ms ease, transform 200ms ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 640px) {
  .toast-region {
    right: 24px;
    bottom: calc(24px + env(safe-area-inset-bottom));
    left: 24px;
  }
}
