/*
 * Hive Study — frontend design tokens and minimal component examples
 * Version 1.0.0
 *
 * Include once after an existing reset, if present. Inter is a preferred font;
 * this file does not fetch fonts or require a package. Reuse the project's
 * existing font setup, or accept the system fallback.
 *
 * Light is the default. Set data-theme="dark" on <html> for dark mode.
 * Resolve a saved preference or the OS preference in application code if needed.
 * Both token themes are mirrored in tokens.json.
 */

:root {
  color-scheme: light;

  /* Fixed brand palette; semantic colors below are used in components. */
  --brand-amber: #F5A623;
  --brand-navy: #17243A;
  --brand-warm-white: #FAFAF7;
  --brand-soft-gray: #E8EDF3;

  /* Light semantic colors. Subtle borders are decorative, not control edges. */
  --color-bg: #FAFAF7;
  --color-surface: #FFFFFF;
  --color-surface-subtle: #F3F5F8;
  --color-text: #17243A;
  --color-text-secondary: #526175;
  --color-border-subtle: #D7DEE8;
  --color-border-control: #7B8798;
  --color-accent: #F5A623;
  --color-accent-hover: #E99A15;
  --color-accent-pressed: #D98B10;
  --color-on-accent: #17243A;
  --color-link: #2458A6;
  --color-focus: #2458A6;
  --color-success: #166534;
  --color-warning: #854D0E;
  --color-error: #B42318;
  --color-info: #1E40AF;

  /* 1rem follows the user's browser font preference; nominal sizes assume 16px. */
  --font-family-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;
  --font-size-3xl: 2.5rem;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --line-height-tight: 1.2;
  --line-height-body: 1.5;
  --line-height-comfortable: 1.65;

  /* 4px spacing scale at the default 16px root size. */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  --radius-xs: 0.25rem;
  --radius-button: 0.5rem;
  --radius-input: 0.75rem;
  --radius-card: 1rem;
  --radius-pill: 999px;
  --shadow-card: 0 4px 16px rgb(23 36 58 / 0.06);
  --shadow-popover: 0 12px 32px rgb(23 36 58 / 0.14);

  --motion-duration-fast: 120ms;
  --motion-duration-standard: 180ms;
  --motion-duration-slow: 240ms;
  --motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);

  --layout-content-max: 75rem;
  --layout-readable-max: 42rem;
  --layout-sidebar-width: 15rem;
  --layout-gutter-mobile: 1rem;
  --layout-gutter-tablet: 1.5rem;
  --layout-gutter-desktop: 2rem;
  --layout-gutter: var(--layout-gutter-mobile);
  --control-min-size: 2.75rem;
  --border-width: 1px;
  --focus-width: 3px;
  --focus-offset: 3px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #101B2B;
  --color-surface: #17243A;
  --color-surface-subtle: #213149;
  --color-text: #F4F7FB;
  --color-text-secondary: #B4C0D0;
  --color-border-subtle: #34455C;
  --color-border-control: #76879D;
  --color-accent: #F5A623;
  --color-accent-hover: #E99A15;
  --color-accent-pressed: #D98B10;
  --color-on-accent: #17243A;
  --color-link: #A9C7FF;
  --color-focus: #A9C7FF;
  --color-success: #86EFAC;
  --color-warning: #FCD34D;
  --color-error: #FDA29B;
  --color-info: #A9C7FF;
  --shadow-card: 0 4px 16px rgb(0 0 0 / 0.20);
  --shadow-popover: 0 12px 32px rgb(0 0 0 / 0.32);
}

/* Breakpoints are literal CSS media-query values; custom properties cannot be
 * used as media-query conditions. They also appear in tokens.json.
 * Tablet: 768px. Persistent sidebar: 1024px. Large desktop: 1280px.
 */
@media (min-width: 768px) {
  :root {
    --layout-gutter: var(--layout-gutter-tablet);
  }
}

@media (min-width: 1280px) {
  :root {
    --layout-gutter: var(--layout-gutter-desktop);
  }
}

/* Minimal base styles. No forced root font size and no font download. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family-sans);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-body);
}

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

code,
pre,
kbd,
samp {
  font-family: var(--font-family-mono);
}

img,
svg {
  max-width: 100%;
}

/* Keep the outline and its offset outside clipping/overflow containers. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}

.hive-container {
  width: 100%;
  max-width: var(--layout-content-max);
  margin-inline: auto;
  padding-inline: var(--layout-gutter);
}

.hive-readable {
  max-width: var(--layout-readable-max);
}

.hive-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.hive-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.hive-page-title {
  margin: 0;
  font-size: clamp(var(--font-size-xl), 4vw, var(--font-size-3xl));
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.hive-section-title {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
}

.hive-muted {
  color: var(--color-text-secondary);
}

.hive-link {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.hive-link:hover {
  text-decoration-thickness: 0.14em;
}

.hive-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: var(--control-min-size);
  min-height: var(--control-min-size);
  max-width: 100%;
  padding: var(--space-2) var(--space-4);
  border: var(--border-width) solid var(--color-border-control);
  border-radius: var(--radius-button);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-body);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--motion-duration-fast) var(--motion-easing-standard),
    border-color var(--motion-duration-fast) var(--motion-easing-standard),
    box-shadow var(--motion-duration-fast) var(--motion-easing-standard);
}

.hive-button:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--color-accent-hover);
}

.hive-button:active:not(:disabled):not([aria-disabled="true"]) {
  background: var(--color-accent-pressed);
}

.hive-button--secondary {
  border-color: var(--color-border-control);
  background: var(--color-surface);
  color: var(--color-text);
}

.hive-button--secondary:hover:not(:disabled):not([aria-disabled="true"]),
.hive-button--secondary:active:not(:disabled):not([aria-disabled="true"]) {
  background: var(--color-surface-subtle);
}

.hive-button--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--color-text);
}

.hive-button--ghost:hover:not(:disabled):not([aria-disabled="true"]),
.hive-button--ghost:active:not(:disabled):not([aria-disabled="true"]) {
  background: var(--color-surface-subtle);
}

.hive-button--icon {
  width: var(--control-min-size);
  height: var(--control-min-size);
  padding: var(--space-2);
}

/* aria-disabled communicates state but does not block activation by itself.
 * Application code must prevent the action, or use native disabled on buttons.
 * Disabled labels stay opaque and readable; status is not shown by color alone.
 */
.hive-button:disabled,
.hive-button[aria-disabled="true"] {
  border-color: var(--color-border-subtle);
  background: var(--color-surface-subtle);
  color: var(--color-text-secondary);
  cursor: not-allowed;
}

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

.hive-field {
  display: grid;
  gap: var(--space-2);
}

.hive-field-label {
  font-weight: var(--font-weight-medium);
}

.hive-input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: var(--control-min-size);
  padding: var(--space-2) var(--space-3);
  border: var(--border-width) solid var(--color-border-control);
  border-radius: var(--radius-input);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--font-size-md);
  line-height: var(--line-height-body);
  transition: border-color var(--motion-duration-fast) var(--motion-easing-standard);
}

.hive-input::placeholder {
  color: var(--color-text-secondary);
  opacity: 1;
}

.hive-input[aria-invalid="true"] {
  border-color: var(--color-error);
  box-shadow: inset 0 0 0 1px var(--color-error);
}

.hive-input:disabled {
  background: var(--color-surface-subtle);
  color: var(--color-text-secondary);
  cursor: not-allowed;
}

textarea.hive-input {
  min-height: var(--space-16);
  resize: vertical;
}

.hive-field-hint,
.hive-field-error {
  margin: 0;
  font-size: var(--font-size-sm);
}

.hive-field-hint {
  color: var(--color-text-secondary);
}

.hive-field-error {
  color: var(--color-error);
}

.hive-card {
  min-width: 0;
  padding: var(--space-6);
  border: var(--border-width) solid var(--color-border-subtle);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.hive-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border: var(--border-width) solid var(--color-border-subtle);
  border-radius: var(--radius-pill);
  background: var(--color-surface-subtle);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-body);
}

.hive-status {
  padding: var(--space-3) var(--space-4);
  border-inline-start: var(--focus-width) solid currentColor;
  border-radius: var(--radius-xs);
  background: var(--color-surface-subtle);
  color: var(--color-info);
}

.hive-status--success { color: var(--color-success); }
.hive-status--warning { color: var(--color-warning); }
.hive-status--error { color: var(--color-error); }

.hive-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.hive-skip-link {
  position: fixed;
  inset-block-start: var(--space-3);
  inset-inline-start: var(--space-3);
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-button);
  background: var(--color-surface);
  color: var(--color-link);
  transform: translateY(calc(-100% - var(--space-6)));
}

.hive-skip-link:focus-visible {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-duration-fast: 0ms;
    --motion-duration-standard: 0ms;
    --motion-duration-slow: 0ms;
  }

  html:focus-within {
    scroll-behavior: auto;
  }
}

/* A complete implementation still needs semantic HTML, visible labels, keyboard
 * behavior, focus management, validation, and service integration. These classes
 * provide a visual foundation; they do not supply application functionality.
 */
