@import url("./codex-theme.css");

/* payback: 8px spacing grid, three type sizes, three weights. */
:root {
  --font-family: 'Sunghyun Sans', sans-serif;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 2.5rem;
  --space-6: 3rem;
  --space-8: 4rem;
  --text-sm: 0.875rem;
  --text-md: 1.5rem;
  --text-lg: 2rem;
  --leading-sm: 1.25rem;
  --leading-md: 2rem;
  --leading-lg: 2.5rem;
  --weight-light: 200;
  --weight-regular: 400;
  --weight-semibold: 600;
  --radius-small: 0.5rem;
  --radius-control: 1rem;
  --radius-card: 1.5rem;
  --card-padding: 1.5rem;
  --control-height: 3rem;
  --button-spinner-size: 1.25rem;
  /* Eight equal-width spokes, drawn locally so loading never waits on an image. */
  --loading-spokes-mask:
    radial-gradient(circle closest-side, transparent 41.667%, #000 41.667% 83.333%, transparent 83.333%) intersect,
    linear-gradient(0deg, transparent 45.833%, #000 45.833% 54.167%, transparent 54.167%) add,
    linear-gradient(90deg, transparent 45.833%, #000 45.833% 54.167%, transparent 54.167%) add,
    linear-gradient(45deg, transparent 47.054%, #000 47.054% 52.946%, transparent 52.946%) add,
    linear-gradient(135deg, transparent 47.054%, #000 47.054% 52.946%, transparent 52.946%);
  /* Colors are mapped from the imported Codex theme snapshot. */
  --color-background: var(--codex-background);
  --color-surface: var(--codex-surface);
  --color-surface-subtle: var(--codex-surface-subtle);
  --color-text: var(--codex-text);
  /* Shared subtle gray, matched to the group action icon reference. */
  --color-text-muted: #666666;
  --color-border: var(--codex-border);
  --color-control-border: var(--codex-control-border);
  --color-accent: var(--codex-accent);
  --color-accent-text: var(--codex-accent-text);
  --color-primary: var(--color-accent);
  --color-primary-hover: color-mix(in srgb, var(--color-accent) 88%, black);
  --color-on-primary: #FFFFFF;
  --color-primary-soft: var(--codex-accent-soft);
  --color-success: var(--codex-success);
  --color-success-soft: var(--codex-success-soft);
  --color-warning: var(--codex-warning);
  --color-warning-soft: var(--codex-warning-soft);
  --color-error: var(--codex-error);
  --color-error-soft: var(--codex-error-soft);
  /* Shared open-menu treatment, matched to the app's select menus. */
  --menu-background: color-mix(in srgb, var(--color-text) 2.5%, var(--color-background));
  --menu-border-color: rgb(255 255 255 / 10%);
  --menu-border: 1px solid var(--menu-border-color);
  --menu-radius: .75rem;
  --menu-shadow: 0 8px 24px rgb(0 0 0 / 28%);
  --menu-field-background: color-mix(in srgb, var(--color-text) 5%, transparent);
  --menu-field-focus: inset 0 0 0 1px rgb(255 255 255 / 12%);
  --menu-field-height: 2.75rem;
}

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

.loading-indicator { display:inline-flex; align-items:center; gap:.5rem; vertical-align:middle; }
.loading-spinner { display:inline-block; width:var(--button-spinner-size); height:var(--button-spinner-size); flex:none; background:currentColor; mask:var(--loading-spokes-mask); animation:loading-spokes-spin .8s linear infinite; }
/* An explicit spinner replaces the older context-specific pseudo-element. */
:is(button,.ui-button)[aria-busy="true"]:has(> .loading-indicator)::after { content:none; }
@keyframes loading-spokes-spin { to { transform:rotate(360deg); } }
@media (prefers-reduced-motion:reduce) { .loading-spinner { animation:none; } }
html {
  font-family: var(--font-family);
  font-size: 100%;
  font-weight: var(--weight-regular);
  line-height: var(--leading-sm);
  background: var(--color-background);
  color: var(--color-text);
}
body { min-height: 100vh; margin: 0; font-size: var(--text-sm); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--text-lg); line-height: var(--leading-lg); font-weight: var(--weight-semibold); }
h2 { font-size: var(--text-md); line-height: var(--leading-md); font-weight: var(--weight-semibold); }
h3 { font-size: var(--text-sm); line-height: var(--leading-sm); font-weight: var(--weight-semibold); }
strong, b, th { font-weight: var(--weight-semibold); }
small { font-size: var(--text-sm); }
a { color: var(--color-accent-text); text-underline-offset: 0.25em; }
button, input, select, textarea { font: inherit; }
button, input, select, textarea, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--color-accent-text); outline-offset: 4px; }
::selection { color: var(--color-on-primary); background: var(--color-primary); }

.text-sm { font-size: var(--text-sm); line-height: var(--leading-sm); }
.text-md { font-size: var(--text-md); line-height: var(--leading-md); }
.text-lg { font-size: var(--text-lg); line-height: var(--leading-lg); }
.weight-light { font-weight: var(--weight-light); }
.weight-regular { font-weight: var(--weight-regular); }
.weight-semibold { font-weight: var(--weight-semibold); }
.text-muted { color: var(--color-text-muted); }
.amount { font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

.card {
  min-width: 0;
  padding: var(--card-padding);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  color: var(--color-text);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: var(--control-height);
  padding: var(--space-1) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-sm);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
/* Let button variants override the shared primary hover color. */
.button:where(:not(.login-continue):not(:disabled):hover) { background: var(--color-primary-hover); }
.button--secondary {
  background: var(--color-surface);
  border-color: var(--color-control-border);
  color: var(--color-text);
}
.button--secondary:not(:disabled):hover { background: var(--color-surface-subtle); }
.button--quiet { color: var(--color-accent-text); background: transparent; }
.button--quiet:not(:disabled):hover { background: var(--color-primary-soft); }
.button--pill {
  min-height: 1.875rem;
  gap: .375rem;
  padding: .25rem .625rem;
  border: 0;
  border-radius: 999px;
  background: rgb(255 255 255 / 6%);
  color: #ddd;
  font-weight: var(--weight-regular);
}
.button--pill:not(:disabled):is(:hover, :focus-visible) { background: rgb(255 255 255 / 10%); color: var(--color-text); }
.button--pill svg { width: 1.125rem; height: 1.125rem; flex: none; }
.pill-button-label { min-width: 0; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }

.ui-badge { display: inline-flex; align-items: center; gap: .375rem; padding: .125rem .5rem; border: 1px solid rgb(255 255 255 / 6%); border-radius: .5rem; background: transparent; color: #999; font-size: .8125rem; line-height: 1.25rem; }

.field { display: grid; gap: var(--space-1); }
.field__label { font-weight: var(--weight-semibold); }
.field__help { color: var(--color-text-muted); }
.input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: var(--control-height);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-control-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}
textarea.input { min-height: 6rem; resize: vertical; }
.input::placeholder { color: var(--color-text-muted); opacity: 1; }
.input:hover:not(:disabled) { border-color: var(--color-text); }
.input:focus-visible { border-color: var(--color-primary); }
.input:disabled { opacity: 0.45; cursor: not-allowed; }
.input[aria-invalid="true"] { border-color: var(--color-error); }
.field__error { color: var(--color-error); }

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: var(--space-4);
  padding: 0 var(--space-1);
  border-radius: var(--radius-small);
  background: var(--color-surface-subtle);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  line-height: var(--leading-sm);
}
.badge--success { --badge-dot: var(--color-success); background: var(--color-success-soft); }
.badge--warning { --badge-dot: var(--color-warning); background: var(--color-warning-soft); }
.badge--error { --badge-dot: var(--color-error); background: var(--color-error-soft); }
.badge--success, .badge--warning, .badge--error { color: var(--color-text); gap: var(--space-1); }
.badge--success::before, .badge--warning::before, .badge--error::before {
  content: ""; width: var(--space-1); height: var(--space-1); flex: none;
  border-radius: 50%; background: var(--badge-dot);
}
