/*
 * Interview System design foundation: "Ruhig-professionell".
 * Page-specific styles consume these tokens and shared components.
 */

:root {
  color-scheme: light;
  --bg: #F7F9F8;
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --line: #E2E8E6;
  --ink: #182220;
  --ink-muted: #5C6966;
  --accent: #0E6963;
  --accent-ink: #FFFFFF;
  --accent-soft: #E4F0EE;
  --ok: #2E7D46;
  --warn: #A96A0B;
  --danger: #B3372E;
  --font-sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --shadow-1: 0 1px 2px rgb(24 34 32 / 6%), 0 2px 8px rgb(24 34 32 / 4%);
  --shadow-2: 0 8px 24px rgb(24 34 32 / 8%), 0 2px 8px rgb(24 34 32 / 5%);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131817;
    --surface: #1A201F;
    --surface-raised: #212827;
    --line: #2B3331;
    --ink: #E9EDEB;
    --ink-muted: #94A09C;
    --accent: #53B8AF;
    --accent-ink: #0B1413;
    --accent-soft: #1E2E2C;
    --ok: #5BBF7E;
    --warn: #D99A3D;
    --danger: #E06C60;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 16%), 0 2px 8px rgb(0 0 0 / 10%);
    --shadow-2: 0 8px 24px rgb(0 0 0 / 18%), 0 2px 8px rgb(0 0 0 / 12%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131817;
  --surface: #1A201F;
  --surface-raised: #212827;
  --line: #2B3331;
  --ink: #E9EDEB;
  --ink-muted: #94A09C;
  --accent: #53B8AF;
  --accent-ink: #0B1413;
  --accent-soft: #1E2E2C;
  --ok: #5BBF7E;
  --warn: #D99A3D;
  --danger: #E06C60;
  --shadow-1: 0 1px 2px rgb(0 0 0 / 16%), 0 2px 8px rgb(0 0 0 / 10%);
  --shadow-2: 0 8px 24px rgb(0 0 0 / 18%), 0 2px 8px rgb(0 0 0 / 12%);
}

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

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  background: var(--bg);
  transition: color 180ms ease, background-color 180ms ease;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--ink);
  font-weight: 680;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(1.4rem, 3vw, 1.85rem);
}

h3 {
  font-size: clamp(1.15rem, 2vw, 1.35rem);
}

h4,
h5,
h6 {
  font-size: 1rem;
}

a {
  color: var(--accent);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

label,
legend {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
}

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

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]),
select,
textarea {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  color: var(--ink);
  background: var(--surface);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 180ms ease;
}

textarea {
  min-height: 7rem;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-muted);
  opacity: 0.85;
}

input[type="checkbox"],
input[type="radio"],
input[type="range"] {
  accent-color: var(--accent);
}

input:disabled,
select:disabled,
textarea:disabled,
button:disabled,
.button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

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

:where(.button, button, input[type="submit"], input[type="button"]) {
  display: inline-flex;
  min-height: 2.5rem;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  color: var(--ink);
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

:where(.button--primary, input[type="submit"]) {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
}

.button--secondary {
  border-color: var(--line);
  color: var(--ink);
  background: var(--surface);
}

.button--danger {
  border-color: var(--danger);
  color: var(--accent-ink);
  background: var(--danger);
}

.button-link {
  min-height: 2.25rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  color: var(--ink-muted);
  background: transparent;
  box-shadow: none;
}

.button-link:hover {
  border-color: var(--line);
  color: var(--accent);
  background: var(--accent-soft);
}

@media (hover: hover) {
  :where(.button--primary, input[type="submit"]):hover {
    box-shadow: var(--shadow-1);
    filter: brightness(0.95);
  }

  .button--secondary:hover,
  :where(.button, button):not(.button--primary):not(.button-link):not(.theme-toggle):hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
  }
}

/* Shared application navigation */
.top-nav {
  display: flex;
  min-height: 4rem;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) max(var(--space-4), calc((100vw - 96rem) / 2));
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: border-color 180ms ease, background-color 180ms ease;
}

.top-nav__brand {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-decoration: none;
}

.top-nav__brand:hover {
  color: var(--accent);
}

.top-nav__links {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1) var(--space-3);
}

.top-nav__links form {
  margin: 0;
}

.top-nav__links a {
  padding: 0.4rem 0.15rem;
  color: var(--ink-muted);
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
}

.top-nav__links a:hover,
.top-nav__links a[aria-current="page"],
.top-nav__links a.is-active {
  color: var(--accent);
}

/* Shared flash messages */
.flash-region,
.flash-messages {
  width: min(calc(100% - (2 * var(--space-4))), 96rem);
  margin-inline: auto;
}

.flash-region {
  margin-top: var(--space-4);
}

.flash-region:empty,
.flash-messages:empty {
  display: none;
}

.flash {
  --flash-status: var(--accent);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--flash-status);
  border-radius: var(--radius-m);
  color: var(--ink);
  background: var(--surface-raised);
  box-shadow: var(--shadow-1);
}

.flash--notice,
.flash--success {
  --flash-status: var(--ok);
}

.flash--warning,
.flash--warn {
  --flash-status: var(--warn);
}

.flash--alert,
.flash--error,
.flash--danger {
  --flash-status: var(--danger);
}

/* Reusable UI primitives */
.ui-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  color: var(--ink);
  background: var(--surface-raised);
  box-shadow: var(--shadow-1);
}

.ui-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink);
  font-size: 0.9rem;
}

.ui-table th,
.ui-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
}

.ui-table th {
  color: var(--ink-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--accent-soft);
}

.ui-table tbody tr:last-child td {
  border-bottom: 0;
}

.ui-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: var(--space-1);
  padding: 0.28rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  background: var(--accent-soft);
}

.ui-badge--ok {
  border-color: var(--ok);
  color: var(--ok);
}

.ui-badge--warning {
  border-color: var(--warn);
  color: var(--warn);
}

.ui-badge--danger {
  border-color: var(--danger);
  color: var(--danger);
}

.ui-empty {
  display: grid;
  min-height: 9rem;
  place-items: center;
  padding: var(--space-6);
  border: 1px dashed var(--line);
  border-radius: var(--radius-m);
  color: var(--ink-muted);
  text-align: center;
  background: var(--surface);
}

.ui-empty > :first-child {
  margin-top: 0;
}

.ui-empty > :last-child {
  margin-bottom: 0;
}

/* Theme control shared by interviewer and participant layouts */
.theme-toggle {
  display: inline-grid;
  width: 2.5rem;
  min-width: 2.5rem;
  height: 2.5rem;
  min-height: 2.5rem;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-muted);
  background: var(--surface);
  box-shadow: none;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.theme-toggle__icon {
  font-size: 1.15rem;
  line-height: 1;
}

.participation-shell > .theme-toggle {
  margin: 0 0 var(--space-3) auto;
}

@media (max-width: 48rem) {
  .top-nav {
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
  }

  .top-nav__links {
    order: 3;
    width: 100%;
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .top-nav > .theme-toggle {
    margin-inline-start: auto;
  }

  .ui-table th,
  .ui-table td {
    padding-inline: var(--space-3);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
