/* ========================================
   STMDESKLY
   Base styles
   ======================================== */

/* 1. Reset */

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

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

body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

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

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

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

img,
video {
  height: auto;
}

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

button,
input,
textarea,
select {
  border-radius: 0;
}

textarea {
  resize: vertical;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* 2. Document */

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;

  background: var(--color-page);
  color: var(--color-text);

  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  overflow-wrap: break-word;
}

::selection {
  background: var(--color-brand-soft);
  color: var(--color-text);
}

/* 3. Typography */

h1,
h2,
h3,
h4 {
  color: var(--color-text);
  font-family: var(--font-family);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.035em;
  overflow-wrap: break-word;
}

h1 {
  font-size: var(--text-5xl);
}

h2 {
  font-size: var(--text-4xl);
}

h3 {
  font-size: var(--text-2xl);
}

h4 {
  font-size: var(--text-lg);
}

p {
  line-height: var(--leading-relaxed);
}

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

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

em,
i {
  font-style: normal;
}

code,
pre,
kbd,
samp {
  font-family: monospace;
}

pre {
  overflow-x: auto;
}

/* 4. Links */

a:not([class]) {
  color: var(--color-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:not([class]):hover {
  color: var(--color-brand-hover);
}

/* 5. Form controls */

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
}

button {
  border: 0;
  background: none;
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

input,
select {
  min-height: var(--control-height);
  padding-inline: var(--space-3);
}

textarea {
  min-height: 8rem;
  padding: var(--space-3);
}

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

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

/* 6. Keyboard accessibility */

:focus {
  outline: none;
}

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

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

/* 7. Shared layout */

.container {
  width: min(
    calc(100% - (var(--page-gutter) * 2)),
    var(--container-width)
  );
  margin-inline: auto;
}

.container-narrow {
  width: min(
    calc(100% - (var(--page-gutter) * 2)),
    var(--container-narrow)
  );
  margin-inline: auto;
}

.container-wide {
  width: min(
    calc(100% - (var(--page-gutter) * 2)),
    var(--container-wide)
  );
  margin-inline: auto;
}

/* 8. Common utilities */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: var(--z-toast);

  padding: var(--space-3) var(--space-4);

  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);

  transform: translateY(-160%);
  transition: transform var(--duration-fast) var(--ease-standard);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.text-muted {
  color: var(--color-text-muted);
}

.text-secondary {
  color: var(--color-text-secondary);
}

.text-center {
  text-align: center;
}

.w-full {
  width: 100%;
}

/* 9. Lists and separators */

[hidden] {
  display: none !important;
}

hr {
  height: 1px;
  margin: var(--space-6) 0;
  border: 0;
  background: var(--color-border);
}

ul[role="list"],
ol[role="list"] {
  list-style: none;
}

/* 10. Motion preferences */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 11. Responsive typography */

@media (max-width: 768px) {
  h1 {
    letter-spacing: -0.03em;
  }

  h2 {
    letter-spacing: -0.025em;
  }
}

@media (max-width: 480px) {
  body {
    font-size: var(--text-base);
  }

  h1 {
    font-size: var(--text-4xl);
  }

  h2 {
    font-size: var(--text-3xl);
  }

  h3 {
    font-size: var(--text-xl);
  }
}
