/* monderings.com — base stylesheet
 *
 * Responsive strategy: layout responds to available width, never to browser
 * or device detection. Type and spacing scale fluidly with the viewport via
 * clamp(), and .grid reflows intrinsically, so most of the page adapts with
 * no breakpoints at all. Media queries below handle only the few cases that
 * genuinely need a layout change.
 */

:root {
  --bg: #fdfdfc;
  --fg: #1a1a18;
  --muted: #5f5f58;
  --accent: #7a5c3e;
  --rule: #e2e0da;
  --error: #a4262c;   /* 7.13:1 on --bg */
  --ok: #1e6b3a;      /* 6.41:1 on --bg */

  /* Reading measure. Wider containers opt in with .wrap--wide. */
  --measure: 34rem;
  --measure-wide: 62rem;

  /* Fluid scales: min at ~360px viewport, max at ~1200px, smooth between. */
  --step-0: clamp(1rem, 0.96rem + 0.20vw, 1.0625rem);      /* body      */
  --step-1: clamp(1.15rem, 1.09rem + 0.30vw, 1.3rem);      /* h3        */
  --step-2: clamp(1.35rem, 1.24rem + 0.55vw, 1.65rem);     /* h2        */
  --step-3: clamp(1.65rem, 1.40rem + 1.20vw, 2.4rem);      /* h1        */

  --gutter: clamp(1rem, 0.7rem + 1.5vw, 2rem);
  --block:  clamp(2rem, 1.4rem + 3vw, 4rem);
  --gap:    clamp(1.25rem, 1rem + 1.2vw, 2.25rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --fg: #e8e6e1;
    --muted: #a09e97;
    --accent: #c9a87c;
    --rule: #2c2c32;
    --error: #f2b8b5;   /* 10.57:1 on --bg */
    --ok: #7ddba0;      /* 10.75:1 on --bg */
  }
}

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

body {
  margin: 0;
  padding: var(--block) var(--gutter);
  background: var(--bg);
  color: var(--fg);
  font: var(--step-0)/1.6 Calibri, "Segoe UI", -apple-system, BlinkMacSystemFont,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-wrap: break-word;   /* long URLs can't force a sideways scroll */
}

/* ---------- containers ---------- */

.wrap {
  max-width: var(--measure);
  margin-inline: auto;
}

.wrap--wide {
  max-width: var(--measure-wide);
}

/* Forms aren't prose — they don't need a 34rem reading measure, and that
   width left the fields looking cramped under a much wider header. */
.wrap--form {
  max-width: 46rem;
}

/* ---------- typography ---------- */

h1,
h2,
h3 {
  line-height: 1.2;
  font-weight: 600;
  margin: var(--gap) 0 0.6em;
  text-wrap: balance;          /* avoids one-word orphan lines in headings */
}

h1 { font-size: var(--step-3); margin-top: 0; }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }

p {
  margin: 0 0 1.15rem;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

a:hover { text-decoration: none; }

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

/* WCAG 2.4.1 Bypass Blocks — offscreen until focused, then visible. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.6rem 1rem;
  background: var(--bg);
  color: var(--accent);
  border: 2px solid var(--accent);
  border-radius: 0 0 4px 0;
  z-index: 10;
}

.skip-link:focus {
  left: 0;
}

/* Programmatic focus target for the skip link; no stray outline on click. */
#main:focus {
  outline: none;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--gap) 0;
}

.muted {
  color: var(--muted);
  font-size: 0.9em;
}

/* ---------- site chrome ---------- */

.site-header {
  display: flex;
  flex-wrap: wrap;             /* nav drops below the title when space runs out */
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem var(--gap);
  margin-bottom: var(--gap);
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}

.site-title {
  font-size: var(--step-1);
  font-weight: 600;
  margin: 0;
}

.site-title a {
  color: inherit;
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem var(--gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: inline-block;
  padding: 0.35rem 0;          /* keeps taps comfortably large on touch */
}

.site-footer {
  margin-top: var(--block);
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

/* ---------- layout ---------- */

/* Reflows on its own: as many columns as fit at --col-min, no breakpoints. */
.grid {
  --col-min: 16rem;
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(var(--col-min), 100%), 1fr));
}

.grid--wide  { --col-min: 22rem; }
.grid--tight { --col-min: 11rem; }

/* Sidebar that sits alongside on wide screens and stacks when it can't. */
.with-sidebar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}

.with-sidebar > :first-child { flex: 1 1 22rem; }
.with-sidebar > :last-child  { flex: 1 1 14rem; }

/* ---------- media & overflow ---------- */

img,
video,
svg,
canvas {
  max-width: 100%;
  height: auto;
}

img {
  display: block;
}

iframe {
  max-width: 100%;
  border: 0;
}

/* Wide content scrolls inside its own box rather than the page going sideways. */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

pre {
  overflow-x: auto;
  padding: 1rem;
  background: color-mix(in srgb, var(--fg) 5%, transparent);
  border-radius: 4px;
}

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

th,
td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}

/* ---------- breakpoints (only where reflow isn't enough) ---------- */

/* Narrow phones: reclaim horizontal space taken by the body gutter. */
@media (max-width: 26rem) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Coarse pointers get larger hit areas. */
@media (pointer: coarse) {
  .site-nav a { padding: 0.6rem 0; }
}

@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;
  }
}

@media print {
  body { padding: 0; color: #000; background: #fff; }
  .site-nav, .site-footer { display: none; }
  a { text-decoration: underline; }
}

/* ---------- forms ---------- */

.form {
  margin-top: var(--gap);
}

.field {
  margin-bottom: var(--gap);
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.req {
  font-weight: 400;
  color: var(--muted);
}

/* Fill the form column rather than sitting in a narrow stub of it. */
input[type="text"],
input[type="email"],
textarea {
  display: block;
  width: 100%;
  max-width: 38rem;
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 4px;
  min-height: 2.75rem;          /* comfortably over the 24px 2.5.8 minimum */
}

textarea {
  min-height: 9rem;
  resize: vertical;
  line-height: 1.5;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--error);
  border-width: 2px;
}

.hint {
  margin: 0.3rem 0 0;
  font-size: 0.9em;
  color: var(--muted);
}

.field-error {
  margin: 0.35rem 0 0;
  font-size: 0.95em;
  font-weight: 600;
  color: var(--error);
}

.button {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  min-height: 2.75rem;
  font: inherit;
  font-weight: 600;
  color: var(--bg);
  background: var(--fg);
  border: 2px solid var(--fg);
  border-radius: 4px;
  cursor: pointer;
}

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

/* ---------- notices ---------- */

.notice {
  margin: var(--gap) 0;
  padding: 1rem 1.15rem;
  border-left: 4px solid var(--rule);
  background: color-mix(in srgb, var(--fg) 4%, transparent);
  border-radius: 0 4px 4px 0;
}

.notice p:last-child,
.notice ul:last-child {
  margin-bottom: 0;
}

.notice ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.notice--error {
  border-left-color: var(--error);
}

.notice--error a {
  color: var(--error);
}

.notice--ok {
  border-left-color: var(--ok);
}

/* Honeypot: out of sight, out of the tab order, out of the a11y tree. */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

[aria-current="page"] {
  font-weight: 600;
  text-decoration: none;
}
