/* =========================================================================
   Dentora — Base styles
   Reset, document defaults, typography, links, media, forms, a11y helpers.
   Consumes tokens.css. Contains no component styles.
   ========================================================================= */

/* ---------- 1. Reset ---------------------------------------------------- */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Anchor targets clear the sticky header instead of hiding beneath it. */
  scroll-padding-top: calc(var(--header-height) + var(--space-4));
}

@media (prefers-reduced-motion: no-preference) {
  html:focus-within {
    scroll-behavior: smooth;
  }
}

body {
  min-height: 100svh;
  margin: 0;
  background-color: var(--color-surface-page);
  color: var(--color-text-body);
  font-family: var(--font-body);
  font-size: var(--text-body);
  font-weight: var(--weight-regular);
  line-height: var(--leading-body);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Belt-and-braces against horizontal overflow from any single child. */
  overflow-x: clip;
}

/* Reserve space for the mobile sticky action bar so it never covers
   the last element on the page. Cleared at >=768px where the bar hides. */
@media (max-width: 767px) {
  body {
    padding-bottom: calc(
      var(--mobile-bar-height) + env(safe-area-inset-bottom, 0px)
    );
  }
}

/* ---------- 2. Media ---------------------------------------------------- */

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

img,
video {
  height: auto;
}

/* Photography keeps its aspect ratio and crops rather than stretching. */
img {
  object-fit: cover;
  background-color: var(--color-surface-alt);
}

/* Do NOT set `fill` on svg here. A CSS declaration beats the `fill="none"`
   presentation attribute the icon set relies on, which would flood every
   outline icon with solid colour. Icons inherit colour via `stroke` /
   `fill` set on the element itself. */

/* ---------- 3. Typography ----------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  font-weight: var(--weight-bold);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
  color: var(--color-text-strong);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-h1);
  line-height: var(--leading-heading-tight);
}
h2 {
  font-size: var(--text-h2);
}
h3 {
  font-size: var(--text-h3);
  font-weight: var(--weight-semibold);
}
h4 {
  font-size: var(--text-h4);
  font-weight: var(--weight-semibold);
}
h5,
h6 {
  font-size: var(--text-body-lg);
  font-weight: var(--weight-semibold);
}

p {
  text-wrap: pretty;
}

p,
li,
dd,
dt,
figcaption {
  overflow-wrap: break-word;
}

strong,
b {
  font-weight: var(--weight-semibold);
  color: var(--color-text-strong);
}

small {
  font-size: var(--text-small);
}

ul,
ol {
  padding-left: 1.25em;
}

hr {
  height: var(--border-width);
  border: 0;
  background-color: var(--color-border);
}

/* ---------- 4. Links ---------------------------------------------------- */

a {
  color: var(--color-teal-700);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: var(--transition-color);
}

a:hover {
  color: var(--color-navy);
}

/* Links inside body copy stay underlined: colour is never the only signal
   that something is a link (WCAG 1.4.1). Navigation and buttons opt out
   via their own component styles. */
a:not([class]) {
  text-decoration: underline;
}

/* ---------- 5. Focus ---------------------------------------------------- */

/* Always-visible, high-contrast focus ring on keyboard navigation.
   :focus-visible keeps it off for mouse users without hiding it entirely. */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* On navy surfaces the teal ring loses contrast, so switch to white. */
.on-dark :focus-visible,
.on-dark:focus-visible {
  outline-color: var(--color-white);
}

/* Remove the ring only where :focus-visible is supported and not matched. */
:focus:not(:focus-visible) {
  outline: none;
}

/* ---------- 6. Forms ---------------------------------------------------- */

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

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

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

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

label {
  display: inline-block;
  font-size: var(--text-small);
  font-weight: var(--weight-medium);
  color: var(--color-text-strong);
  line-height: var(--leading-ui);
}

/* Baseline control styling. The full field component lands with the
   appointment/contact forms; this keeps any early markup consistent. */
input[type='text'],
input[type='tel'],
input[type='email'],
input[type='date'],
input[type='time'],
input[type='search'],
textarea,
select {
  width: 100%;
  min-height: 50px;
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-white);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-input);
  color: var(--color-text-body);
  transition:
    border-color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--color-teal);
  box-shadow: var(--shadow-focus);
}

/* Native validation styling is suppressed; errors are announced in markup
   by the form component so the message is never colour-only. */
input:invalid,
textarea:invalid {
  box-shadow: none;
}

/* ---------- 7. Tables --------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: var(--border);
}

th {
  font-weight: var(--weight-semibold);
  color: var(--color-text-strong);
}

/* ---------- 8. Accessibility helpers ------------------------------------ */

/* Visually hidden but available to assistive technology. */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Skip link — the first focusable element on every page. */
.skip-link {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: var(--z-skip-link);
  padding: var(--space-3) var(--space-5);
  background-color: var(--color-navy);
  color: var(--color-white);
  font-size: var(--text-small);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-button);
  text-decoration: none;
  transform: translateY(calc(-100% - var(--space-4)));
  transition: transform var(--duration-base) var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
  color: var(--color-white);
}

/* Global reduced-motion guard. Individual components do not need to
   repeat this; anything essential (e.g. menu height) still functions. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Honour forced-colours / Windows high contrast mode. */
@media (forced-colors: active) {
  :focus-visible {
    outline-color: Highlight;
  }
}
