/* ==========================================================================
   RESET
   ========================================================================== */

/* reset rules... */

/* 1) Box sizing */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 2) Remove default margin */
html,
body {
  margin: 0;
  padding: 0;
}

/* 3) Sensible line height */
body {
  line-height: 1.5;
}

/* 4) Media elements behave */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

/* 5) Form elements inherit typography */
input,
button,
textarea,
select {
  font: inherit;
}

/* 6) Make buttons clickable */
button {
  cursor: pointer;
}

/* 7) Prevent long words from breaking layouts */
h1,
h2,
h3,
h4,
h5,
h6,
p {
  overflow-wrap: break-word;
}


/* ==========================================================================
   BASE
   ========================================================================== */

/* typography, colors, variables... */

/* Design tokens */
:root {
  --color-bg: #ffffff;
  --color-text: #1f2933;
  --color-muted: #6b7280;
  --color-accent: #2563eb;
  --color-border: #e5e7eb;
  --color-placeholder: #9ca3af;

  --font-body: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  --radius: 0.375rem;
}

/* Base document styles */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;

  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text);
  background-color: var(--color-bg);
}

/* Headings */
h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin-bottom: var(--space-2);
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.25rem;
}

/* Text */
p {
  margin-bottom: var(--space-4);
}

ul {
  padding-left: 1.25rem;
  margin-bottom: var(--space-4);
}

li {
  margin-bottom: var(--space-2);
}

/* Links */
a {
  color: var(--color-accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration: underline;
}

/* Buttons */
button {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}

/* Muted utility */
.muted {
  color: var(--color-muted);
}

/* Focus styles (keyboard-visible) */
:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-2);
  background: var(--color-bg);
  color: var(--color-text);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.skip-link:focus {
  top: var(--space-2);
}


/* ==========================================================================
   LAYOUT
   ========================================================================== */

/* containers, grid, flex layouts... */

body > header,
body > main,
body > footer {
  padding: var(--space-6) var(--space-4);
}

main {
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  flex: 1;
}

body > header {
  border-bottom: 1px solid var(--color-border);
}

body > footer {
  border-top: 1px solid var(--color-border);
}

.footer-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

/* Nav layout */
nav[aria-label="Primary navigation"] {
  max-width: 72rem;
  margin: 0 auto;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

nav[aria-label="Primary navigation"] > a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 700;
}

#primary-nav {
  list-style: none;
  padding: 0;
  margin: 0;

  display: flex;
  align-items: center;
  gap: var(--space-3);
}

#primary-nav a {
  color: var(--color-text);
  text-decoration: none;
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius);
}

#primary-nav a:hover {
  background: #f3f4f6;
}

/* Mobile: collapse nav links by default */
@media (max-width: 40rem) {
  #primary-nav {
    width: 100%;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-3);
    display: none; /* JS will toggle */
  }

  /* When JS opens it */
  #primary-nav[data-open="true"] {
    display: flex;
  }

  section {
    padding: var(--space-2) 0;
  }
}

/* Desktop: hide toggle, always show nav */
@media (min-width: 40.001rem) {
  #nav-toggle {
    display: none;
  }
}


/* ==========================================================================
   COMPONENTS
   ========================================================================== */

/* buttons, cards, forms, navigation... */

/* Simple content sections */
section {
  padding: var(--space-6) 0;
}

section + section {
  border-top: 1px solid var(--color-border);
}

/* Card */
.card {
  border: 1px solid var(--color-border);
  border-radius: calc(var(--radius) * 2);
  padding: var(--space-6);
  background: var(--color-bg);
  max-width: 64rem;
  margin: 0 auto;
}

/* Button variants */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);

  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  text-decoration: none;
  padding: var(--space-2) var(--space-4);
}

.button:hover {
  background: #f3f4f6;
}

.button.primary {
  border-color: var(--color-accent);
  color: #ffffff;
  background: var(--color-accent);
}

.button.primary:hover {
  filter: brightness(0.95);
}

/* Inline code */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
  padding: 0.1em 0.25em;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #f9fafb;
}

/* Utility: visually separated list */
.list-clean {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-clean > li + li {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.field:first-child {
  margin-top: 0;
}

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

input,
select,
textarea {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
}

input::placeholder, textarea::placeholder {
  color: var(--color-placeholder);
  opacity: 1; /* Ensures consistent rendering across browsers */
}

.error {
  min-height: 1.25em;
  margin: 0;
  color: #b91c1c;
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: #b91c1c;
}

textarea {
  resize: none;
}

select:invalid { color: var(--color-placeholder); }
select:valid { color: var(--color-text); }
option { color: var(--color-text); }

/* Gallery */
.gallery {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(1, 1fr);
}

figure {
  margin: 0;
}

figure img {
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

figcaption {
  margin-top: var(--space-2);
}
