/* Global design tokens and base styles (P07).
   Visual direction: inspired by the "Oakridge Carpenter and Joinery" theme (owner reference) — warm neutrals,
   one yellow accent, Instrument Sans, pill buttons, generous whitespace. Own implementation, no theme code. */

/* Instrument Sans, variable weight 400–700, self-hosted (SIL OFL 1.1, see fonts/instrument-sans/LICENSE). */
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url("fonts/instrument-sans/instrument-sans-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url("fonts/instrument-sans/instrument-sans-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Colours — contrast pairs are checked by DesignTokenTests (WCAG AA). */
  --color-primary: #f2b80d;
  --color-primary-hover: #dca70a;
  --color-on-primary: #1c1917;
  --color-text: #303030;
  --color-muted: #6b6b73;
  --color-border: #d4d4d8;
  --color-surface: #ffffff;
  --color-surface-alt: #fafaf9;
  --color-dark: #44403c;
  --color-darker: #292524;
  --color-on-dark: #ffffff;
  --color-muted-on-dark: #d6d3d1;
  --color-focus: #1f6feb;

  /* Typography */
  --font-sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --text-xs: 0.875rem;
  --text-sm: 1rem;
  --text-base: 1.125rem;
  --text-lg: clamp(1.125rem, 0.9rem + 0.6vw, 1.375rem);
  --text-xl: clamp(1.5rem, 1.1rem + 1.2vw, 2rem);
  --text-2xl: clamp(2rem, 1.4rem + 2vw, 3rem);
  --text-3xl: clamp(2.5rem, 1.6rem + 3.2vw, 4rem);
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --leading-tight: 1.2;
  --leading-body: 1.65;
  --tracking-eyebrow: 0.12em;

  /* Spacing (fluid, mobile → desktop) */
  --space-2xs: clamp(0.3rem, 1vw, 0.625rem);
  --space-xs: clamp(0.625rem, 2vw, 1.25rem);
  --space-sm: clamp(1.25rem, 4vw, 2.5rem);
  --space-md: clamp(1.875rem, 6vw, 3.75rem);
  --space-lg: clamp(2.5rem, 8vw, 5rem);
  --space-xl: clamp(3.125rem, 10vw, 6.25rem);
  --space-2xl: clamp(3.75rem, 12vw, 7.5rem);

  /* Layout */
  --content-width: 75rem;
  --narrow-width: 48rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  --radius-pill: 100px;
  --radius-image: 0.75rem;
  --header-height: 4.5rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--color-text);
  background: var(--color-surface);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.5em;
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

p {
  margin: 0 0 1em;
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-color: var(--color-primary);
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

/* Programmatic focus of the page heading after navigation (FocusOnNavigate) needs no outline. */
h1:focus {
  outline: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.65rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-outline {
  border-color: var(--color-border);
  color: var(--color-text);
  background: transparent;
}

.btn-outline:hover {
  border-color: var(--color-text);
}

.btn-on-dark {
  border-color: rgb(255 255 255 / 0.5);
  color: var(--color-on-dark);
  background: transparent;
}

.btn-on-dark:hover {
  border-color: var(--color-on-dark);
}

.btn-lg {
  min-height: 3.25rem;
  padding: 0.85rem 2rem;
  font-size: var(--text-base);
}

/* Forms (shared by account and admin pages) */
.validation-message {
  color: #b42318;
}

.invalid {
  outline: 1px solid #b42318;
}

/* Blazor error UI */
#blazor-error-ui {
  color-scheme: light only;
  background: #fff8db;
  bottom: 0;
  box-shadow: 0 -1px 2px rgb(0 0 0 / 0.2);
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem 0.7rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

/* Language selector — shared by public, account and admin layouts. */
.language-selector ul {
  display: flex;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.language-selector a {
  display: inline-block;
  min-width: 2.5rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.05em;
  text-align: center;
  text-decoration: none;
  color: var(--color-muted);
}

.language-selector a[aria-current="true"] {
  background: var(--color-surface-alt);
  color: var(--color-text);
  box-shadow: inset 0 0 0 1px var(--color-border);
}

.blazor-error-boundary {
  background: #b32121;
  padding: 1rem;
  color: #fff;
}

.blazor-error-boundary::after {
  content: "An error has occurred.";
}

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

/* Error page for unhandled exceptions (Hosting/ErrorPage.cs, no layout) */
.error-page {
  max-width: 36rem;
  margin: 4rem auto;
  padding: 0 1rem;
  color: var(--color-text);
}

.error-page section + section {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}
