/* Tirly component base. Colors come from tokens.css. No hex in this file. */

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

html {
  background: var(--color-bg);
  color: var(--color-text);
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: var(--lh-body);
}

h1,
.h1 {
  margin: 0 0 var(--space-4);
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  font-weight: 400;
  line-height: var(--lh-h1);
  letter-spacing: var(--ls-h1);
  text-transform: uppercase;
}

.display-xl {
  font-family: var(--font-display);
  font-size: var(--fs-display-xl);
  font-weight: 400;
  line-height: var(--lh-display-xl);
  letter-spacing: var(--ls-display-xl);
  text-transform: uppercase;
}

h2,
.h2 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: 400;
  line-height: var(--lh-h2);
  text-transform: uppercase;
}

h3,
.h3 {
  margin: 0 0 var(--space-2);
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 400;
  line-height: var(--lh-h3);
  text-transform: uppercase;
}

p {
  margin: 0 0 var(--space-4);
}

.num {
  font-family: var(--font-display);
  font-size: var(--fs-number);
  line-height: var(--lh-number);
}

.subtitle {
  font-family: var(--font-title);
  font-size: var(--fs-subtitle);
  font-weight: 500;
  line-height: var(--lh-subtitle);
}

.small {
  margin: 0;
  color: var(--color-muted-2);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
}

.label,
.tag {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  line-height: var(--lh-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.micro {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 500;
  line-height: var(--lh-micro);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--color-muted-2);
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 46px;
  padding: 12px 20px;
  border: var(--outline);
  border-color: var(--color-muted);
  border-radius: var(--radius-button);
  background: transparent;
  color: var(--color-text);
  box-shadow: none;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  line-height: 16px;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: box-shadow 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn--lg {
  padding: 20px 28px;
  font-size: 0.875rem;
  line-height: 16px;
  letter-spacing: 0.12em;
}

/* Color hierarchy: green means clickable and a screen has ONE solid green button (Primary). */
.btn--primary {
  border-color: var(--color-outline);
  background: var(--color-accent);
  color: var(--color-on-accent);
  box-shadow: var(--shadow-hard-sm);
}

.btn--secondary {
  border-color: var(--color-muted);
  background: transparent;
  color: var(--color-text);
  box-shadow: none;
}

.btn--ghost {
  min-height: 0;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--color-text);
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn--danger {
  border-color: var(--color-outline);
  background: var(--color-danger);
  color: var(--color-on-accent);
  box-shadow: var(--shadow-hard-sm);
}

.btn--discord {
  border-color: var(--color-outline);
  background: var(--color-discord);
  color: var(--color-white);
  box-shadow: var(--shadow-hard-sm);
}

.btn--primary:hover,
.btn--danger:hover,
.btn--discord:hover {
  box-shadow: var(--shadow-hard);
}

.btn--secondary:hover,
.btn--secondary:focus-visible,
.btn:not(.btn--primary, .btn--danger, .btn--discord, .btn--ghost):hover,
.btn:not(.btn--primary, .btn--danger, .btn--discord, .btn--ghost):focus-visible {
  border-color: var(--color-accent);
}

.btn--ghost:hover,
.btn--ghost:focus-visible {
  box-shadow: none;
  color: var(--color-accent);
}

.btn--primary:active,
.btn--danger:active,
.btn--discord:active {
  box-shadow: var(--shadow-hard);
}

/* Figma shows no focus ring on Primary. Kept for keyboard users: an outline paints outside the box, so nothing moves. */
.btn:focus-visible,
.input:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary:disabled,
.btn--primary[aria-disabled="true"],
.btn--danger:disabled,
.btn--danger[aria-disabled="true"],
.btn--discord:disabled,
.btn--discord[aria-disabled="true"] {
  box-shadow: var(--shadow-hard-sm);
}

.btn--secondary:disabled,
.btn--secondary[aria-disabled="true"],
.btn--ghost:disabled,
.btn--ghost[aria-disabled="true"] {
  box-shadow: none;
}

.btn[aria-busy="true"] {
  cursor: progress;
}

.btn[aria-busy="true"]::after {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}

.card,
.panel {
  background: var(--color-surface);
  color: var(--color-text);
  border: var(--outline);
}

.card {
  border-radius: var(--radius-card);
  padding: var(--space-6);
  box-shadow: var(--shadow-accent-lg);
}

/* Shadow colour modifiers. Default is green (accent). */
.card--shadow-2 {
  box-shadow: var(--shadow-accent-2-lg);
}

.card--shadow-ink {
  box-shadow: var(--shadow-hard);
}

/* Flat card: surface, no border, no shadow. Panel Home and nothing else at first level. */
.card--flat {
  border: 0;
  background: var(--color-surface);
  box-shadow: none;
}

/* Card inside another card: surface-2, no border, no shadow. */
.card--nested {
  border: 0;
  background: var(--color-surface-2);
  box-shadow: none;
}

/* Highlighted card: green border with a violet 6px shadow (join CTA, passkey modal). */
.card--featured {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-accent-2-lg);
}

.panel {
  border-radius: var(--radius-panel);
  padding: var(--space-5);
  box-shadow: none;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: var(--space-1) var(--space-2);
  border: 0;
  border-radius: 999px;
  background: var(--color-surface-2);
  color: var(--color-text);
}

.tag--outline {
  border: 2px solid var(--color-muted);
  background: transparent;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
}

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

.input {
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  border: var(--outline);
  border-radius: var(--radius-button);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-accent);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  line-height: 22px;
}

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

.input:hover {
  border-color: var(--color-text);
}

.input:focus {
  border-color: var(--color-accent);
}

.input[aria-invalid="true"] {
  border-color: var(--color-danger);
}

.input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.field-error {
  margin: 0;
  color: var(--color-danger);
  font-size: var(--fs-small);
  line-height: var(--lh-small);
}

.label,
.tag {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  line-height: var(--lh-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.micro {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 500;
  line-height: var(--lh-micro);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--color-muted-2);
}

.toast {
  background: var(--color-surface);
  color: var(--color-text);
  border: var(--outline);
  box-shadow: var(--shadow-hard);
  border-radius: var(--radius-card);
  padding: var(--space-3) var(--space-4);
  animation: toast-life 5s ease forwards;
}

.toast[role="status"] {
  box-shadow: 6px 6px 0 var(--color-success);
}

.toast[role="alert"] {
  box-shadow: 6px 6px 0 var(--color-danger);
}

.skeleton {
  display: block;
  height: 16px;
  border-radius: var(--radius-device);
  background: linear-gradient(
    90deg,
    var(--color-surface-2) 0%,
    var(--color-line) 50%,
    var(--color-surface-2) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-sheen 1.2s ease-in-out infinite;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

@keyframes toast-life {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes skeleton-sheen {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

/* Mobile sizes measured on the 390px Figma frames: H1 32/44 (home 6:917, landing 2:942), section titles 20/30, card titles 14.
   The 14px line-height (22) is not in the frames; it is inferred. */
@media (max-width: 640px) {
  :root {
    --fs-display-xl: 32px;
    --lh-display-xl: 44px;
    --fs-h1: 32px;
    --lh-h1: 44px;
    --fs-h2: 20px;
    --lh-h2: 30px;
    --fs-h3: 14px;
    --lh-h3: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .btn[aria-busy="true"]::after,
  .toast,
  .skeleton {
    animation: none;
    transition: none;
  }

  .skeleton {
    background: var(--color-surface-2);
  }
}
