/* Components, written as plain classes with the sizes, radii and states of Vibe's
   shadcn/ui components (see docs/ui-notes.md for the mapping). */

/* ---- Icons ------------------------------------------------------------ */
.icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}
.icon-lg {
  width: 1.25rem;
  height: 1.25rem;
}
.icon-xl {
  width: 1.5rem;
  height: 1.5rem;
}

/* Round tinted icon (CookieBanner / UpdateToast in Vibe). */
.icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  color: var(--primary);
  background: color-mix(in oklch, var(--primary) 15%, transparent);
}
.icon-badge.warn {
  color: var(--warning);
  background: color-mix(in oklch, var(--warning) 15%, transparent);
}
.icon-badge.danger {
  color: var(--destructive);
  background: color-mix(in oklch, var(--destructive) 15%, transparent);
}
.icon-badge.lg {
  width: 3rem;
  height: 3rem;
}
.icon-badge.lg .icon {
  width: 1.375rem;
  height: 1.375rem;
}

/* ---- Brand ------------------------------------------------------------ */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--foreground);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.brand:hover {
  text-decoration: none;
}
.brand img {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-md);
}

/* ---- Button ----------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-shrink: 0;
  height: 2.25rem;
  padding: 0 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition:
    color 0.15s,
    background-color 0.15s,
    box-shadow 0.15s,
    transform 0.15s;
}
.btn:hover {
  background: color-mix(in oklch, var(--primary) 90%, transparent);
  text-decoration: none;
}
.btn:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}
.btn:disabled,
.btn[aria-disabled='true'] {
  pointer-events: none;
  opacity: 0.5;
}
.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}
.btn-secondary:hover {
  background: color-mix(in oklch, var(--secondary) 80%, transparent);
}
.btn-outline {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}
.btn-outline:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}
.btn-ghost {
  background: transparent;
  color: var(--foreground);
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}
.btn-destructive {
  background: var(--destructive-solid);
  color: var(--destructive-foreground);
}
.btn-destructive:hover {
  background: color-mix(in oklch, var(--destructive-solid) 90%, transparent);
}
.btn-link {
  background: transparent;
  color: var(--primary);
  box-shadow: none;
  padding: 0 0.25rem;
}
.btn-link:hover {
  background: transparent;
  text-decoration: underline;
}
.btn-sm {
  height: 2rem;
  gap: 0.375rem;
  padding: 0 0.75rem;
}
.btn-lg {
  height: 2.5rem;
  padding: 0 1.5rem;
}
.btn-xl {
  height: 3rem;
  padding: 0 1.75rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}
.btn-icon {
  width: 2.25rem;
  padding: 0;
}
.btn-icon.btn-sm {
  width: 2rem;
}
.btn-block {
  width: 100%;
}

/* ---- Fields ----------------------------------------------------------- */
.field {
  display: grid;
  gap: 0.375rem;
}
.label {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
}
.input,
.textarea {
  display: block;
  width: 100%;
  min-width: 0;
  height: 2.25rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: transparent;
  box-shadow: var(--shadow-xs);
  font-size: 1rem;
  transition:
    color 0.15s,
    box-shadow 0.15s;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--muted-foreground);
}
.input:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}
.input:disabled,
.textarea:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.textarea {
  height: auto;
  padding: 0.5rem 0.75rem;
  line-height: 1.5;
}
@media (min-width: 768px) {
  .input,
  .textarea {
    font-size: 0.875rem;
  }
}

/* ---- Card ------------------------------------------------------------- */
.card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-sm);
}
.card-header,
.card-content,
.card-footer {
  padding: 0 1rem;
}
.card-header {
  display: grid;
  gap: 0.25rem;
}
.card-header.center {
  justify-items: center;
  text-align: center;
}
.card-title {
  font-weight: 600;
  line-height: 1.2;
}
.card-title.xl {
  font-size: 1.25rem;
}
.card-desc {
  color: var(--muted-foreground);
  font-size: 0.875rem;
}
.card-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---- Badge ------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  flex-shrink: 0;
  padding: 0.125rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.33;
  white-space: nowrap;
}
.badge .icon {
  width: 0.75rem;
  height: 0.75rem;
}
.badge-primary {
  border-color: transparent;
  background: var(--primary);
  color: var(--primary-foreground);
}
.badge-secondary {
  border-color: transparent;
  background: var(--secondary);
  color: var(--secondary-foreground);
}
.badge-muted {
  border-color: transparent;
  background: var(--muted);
  color: var(--muted-foreground);
}
.badge-warn {
  border-color: transparent;
  background: color-mix(in oklch, var(--warning) 18%, transparent);
  color: var(--warning);
}
.badge-danger {
  border-color: transparent;
  background: color-mix(in oklch, var(--destructive) 18%, transparent);
  color: var(--destructive);
}

/* ---- Switch (a checkbox with role="switch") --------------------------- */
.switch {
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  width: 2.25rem;
  height: 1.25rem;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--secondary);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: background-color 0.15s;
}
.switch::after {
  content: '';
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  background: var(--background);
  transform: translateX(0);
  transition: transform 0.15s;
}
.switch:checked {
  background: var(--primary);
}
.switch:checked::after {
  transform: translateX(calc(100% - 2px));
}
.switch:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}

/* ---- Dialog (native <dialog>, Vibe's DialogContent) ------------------- */
.dialog {
  width: calc(100% - 2rem);
  max-width: 32rem;
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 1.5rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--elevated);
  color: var(--foreground);
  box-shadow: var(--shadow-2xl);
}
.dialog[open] {
  display: grid;
  gap: 1rem;
  animation: dialog-in 0.2s ease-out;
}
.dialog::backdrop {
  background: oklch(0 0 0 / 70%);
  backdrop-filter: blur(4px);
}
.dialog-title {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.2;
}
.dialog-desc {
  color: var(--muted-foreground);
}
.dialog-footer {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
}
@media (min-width: 640px) {
  .dialog-footer {
    flex-direction: row;
    justify-content: flex-end;
  }
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---- Language picker (vixus.io's menu: globe + code, a panel of names) - */
/* The panel is a popover (top layer), placed under the toggle by theme.js through --lang-top and
   --lang-edge. No `display` here: the UA rule that hides a closed popover must keep working. */
.lang-picker {
  display: inline-flex;
}
.lang-toggle {
  gap: 0.375rem;
}
.lang-toggle:has(+ .lang-panel:popover-open) {
  background: var(--accent);
  color: var(--accent-foreground);
}
.lang-code {
  min-width: 1.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.lang-panel {
  position: fixed;
  inset: auto;
  top: var(--lang-top, 3rem);
  left: clamp(0.5rem, calc(var(--lang-edge, 100%) - 11rem), calc(100% - 11.5rem));
  width: 11rem;
  margin: 0;
  padding: 0.25rem;
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-2xl);
  transform-origin: top right;
}
.lang-panel:popover-open {
  animation: dialog-in 0.2s ease-out;
}
.lang-panel ul {
  display: grid;
  gap: 0.125rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: start;
}
.lang-option:hover,
.lang-option:focus-visible {
  background: var(--accent);
  color: var(--accent-foreground);
}
.lang-option:focus-visible {
  outline-offset: -2px;
}
.lang-option[aria-current] {
  font-weight: 600;
}
.lang-option .icon {
  color: var(--primary);
}
.lang-option:not([aria-current]) .icon {
  visibility: hidden;
}

/* ---- Notice (Vibe's CookieBanner look) -------------------------------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--elevated);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--muted-foreground);
}
.notice strong {
  color: var(--foreground);
  font-weight: 500;
}
.notice .icon-badge {
  width: 1.75rem;
  height: 1.75rem;
}
.notice .icon-badge .icon {
  width: 0.875rem;
  height: 0.875rem;
}
.notice-body {
  min-width: 0;
  flex: 1;
}

/* ---- Toast (Vibe's UpdateToast) --------------------------------------- */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + var(--safe-bottom));
  z-index: 60;
  display: grid;
  gap: 0.5rem;
  width: min(24rem, calc(100vw - 2rem));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--elevated);
  box-shadow: var(--shadow-2xl);
  pointer-events: auto;
  animation: dialog-in 0.2s ease-out;
}
.toast p {
  font-size: 0.875rem;
  font-weight: 500;
}
.toast p + p {
  margin-top: 0.125rem;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted-foreground);
}

/* ---- Centered auth-style screen (Vibe's AuthScreen) ------------------- */
.screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1rem;
}
.screen .card {
  width: 100%;
  max-width: 26rem;
}
.screen .card.wide {
  max-width: 32rem;
}
.screen .logo {
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-lg);
}

/* ---- Small helpers ---------------------------------------------------- */
.muted {
  color: var(--muted-foreground);
}
.text-xs {
  font-size: 0.75rem;
}
.row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.stack {
  display: grid;
  gap: 1rem;
}
.grow {
  flex: 1;
  min-width: 0;
}
.mono {
  font-family: var(--font-mono);
}
.kbd {
  padding: 0.0625rem 0.375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--muted);
  font-size: 0.75rem;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spin {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
