/* Base: reset, fonts, typography, shared primitives (buttons, inputs,
   spinners, glass, press feedback). Colours come ONLY from the theme's
   CSS variables (js/core/theme.js) — never a literal colour here, same
   rule as mobile's "no hardcoded colours". */

@font-face {
  font-family: 'MaterialCommunityIcons';
  src: url('/assets/fonts/MaterialCommunityIcons.ttf') format('truetype');
  font-display: block;
}

@font-face {
  font-family: 'Crystal';
  src: url('/assets/fonts/crystal.ttf') format('truetype');
  font-display: swap;
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--background);
  color: var(--text);
  /* System font — the computer's own, like mobile uses the phone's
     (planning item 5c). */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
}

#app {
  height: 100%;
}

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

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

/* The hidden attribute always wins over a component's own display rule. */
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Icons ─────────────────────────────────────────────────────────── */
.mdi {
  font-family: 'MaterialCommunityIcons';
  font-style: normal;
  font-weight: normal;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
  user-select: none;
}

.text-accent { color: var(--accent); }
.text-tertiary { color: var(--text-tertiary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* ── Press feedback: mobile's TactilePressable squish (to 92%, 80ms in /
   120ms out). Hover highlight is the web addition (planning item 5f). ── */
.tactile {
  transition: transform 120ms ease-out, background-color 120ms, opacity 120ms;
}
.tactile:active:not(:disabled) {
  transform: scale(0.92);
  transition-duration: 80ms;
}
@media (hover: hover) {
  .hoverable:hover:not(:disabled) {
    background-color: var(--surface);
  }
}

/* ── Glass: mobile's BlurView (intensity 40) treatment ──────────────── */
.glass {
  background-color: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid var(--accent-border);
  font-size: 15px;
  font-weight: 700;
}
.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn--secondary {
  background: var(--background);
  color: var(--text-secondary);
  font-weight: 600;
}
.btn--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--white);
}
.btn--block { width: 100%; }
.btn--wide { min-width: 240px; }
.btn--compact { min-height: 38px; padding: 8px 24px; font-size: 14px; }
.btn:disabled { opacity: 0.6; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
}
.icon-button--small { width: 32px; height: 32px; }
.icon-button--danger .mdi { color: var(--danger); }
@media (hover: hover) {
  .icon-button:hover { background: var(--surface); }
}

/* ── Inputs ────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--surface-alt);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  outline: none;
}
.input::placeholder { color: var(--text-tertiary); opacity: 0.6; }
.input:focus { border-color: var(--accent); }
.input--code {
  text-align: center;
  letter-spacing: 8px;
  font-size: 22px;
}
.input--multiline {
  min-height: 110px;
  resize: vertical;
  line-height: 1.4;
}

.checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin: 0;
}

/* Toggle switch (mobile's <Switch>), drawn from a checkbox. */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--accent-border);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 150ms;
  margin: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 11px;
  background: var(--text);
  transition: transform 150ms;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); background: var(--on-accent); }

/* ── Spinner ───────────────────────────────────────────────────────── */
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--accent-muted);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.spinner--large { width: 36px; height: 36px; border-width: 4px; }
.spinner--on-accent { border-color: var(--accent-border); border-top-color: var(--on-accent); }
.spinner--centered { margin: 24px auto; }
@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-text {
  font-size: 14px;
  color: var(--text-tertiary);
  padding: 12px 0;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
