/* beignet.css — Default HTML, but calmer.
   Inspired by Safari Reader Mode / Apple Newsroom.
   Modern browsers only. Classless. Minimal. */

/* Minimal remedy reset (keep defaults, fix sharp edges) */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

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

/* Avoid long words/URLs blowing up the measure (BUT not tables—tables should scroll) */
p,
li,
blockquote,
pre {
  overflow-wrap: anywhere;
}

/* Make sure form controls inherit fonts consistently */
button,
input,
select,
textarea {
  font: inherit;
}

/* Remove Safari/Chrome default inner focus padding quirks on buttons */
button,
input[type="button"],
input[type="submit"],
input[type="reset"] {
  border: 1px solid var(--line);
}

:root {
  color-scheme: light;

  /* Typography */
  --serif: ui-serif, "New York", "New York Text", "Iowan Old Style", "Palatino",
    "Georgia", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "SF Pro Text",
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Core tokens */
  --bg: Canvas;
  --fg: CanvasText;

  /* Link color: classic HTML default */
  --link: #0000ff;

  /* Very subtle */
  --muted: color-mix(in oklab, var(--fg) 62%, transparent);
  --line: color-mix(in oklab, var(--fg) 8%, transparent);
  --soft: color-mix(in oklab, var(--fg) 5%, transparent);
  --stripe: color-mix(in oklab, var(--fg) 3%, transparent);

  /* Layout */
  --measure: 68ch;
  --pad: clamp(18px, 4vw, 56px);

  /* Shape */
  --radius: 10px;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);

  font-family: var(--serif);
  font-size: 18.5px;
  line-height: 1.7;
  font-weight: 400;

  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "kern", "liga", "clig", "calt";
}

/* Constrain reading width (prefer semantic wrappers if present) */
main,
article,
body > *:first-child {
  max-width: var(--measure);
  margin-inline: auto;
  padding: var(--pad);
}

/* Rhythm */
p {
  margin: 0 0 1.2em 0;
}

ul,
ol,
dl,
blockquote,
pre,
table,
figure {
  margin: 0 0 1.05em 0;
}

li {
  margin: 0.25em 0;
}

/* Headings: understated, editorial */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 1.9em 0 0.65em 0;
  line-height: 1.18;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 2.05em;
  margin-top: 2.2em;
}
h2 {
  font-size: 1.55em;
  margin-top: 2em;
}
h3 {
  font-size: 1.25em;
  margin-top: 1.8em;
}

small,
figcaption {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.92em;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.2em 0;
}

/* Links: classic blue + understated */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: from-font;
  text-underline-offset: 0.15em;
}

/* Quotes: hairline + muted */
blockquote {
  margin-left: 0;
  padding-left: 1.1em;
  border-left: 2px solid var(--line);
  color: var(--muted);
}

/* Inline elements */
strong {
  font-weight: 650;
}
em {
  font-style: italic;
}

/* Code: almost invisible */
code,
kbd,
samp {
  font-family: var(--mono);
  font-size: 0.95em;
}

:not(pre) > code {
  padding: 0.12em 0.32em;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
}

pre {
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 0.95em 1em;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  background: transparent;
}

/* Tables: editorial + horizontal scroll on small screens */
table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 1.2em 0 1.6em;

  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Force overflow instead of wrapping */
th,
td {
  text-align: left;
  padding: 0.65em 0.75em;
  border: 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;

  white-space: nowrap;       /* KEY */
  overflow-wrap: normal;
  word-break: normal;
}

th {
  font-family: var(--sans);
  font-weight: 600;
}

/* Optional: keep your subtle stripes */
tbody tr:nth-child(even) {
  background: var(--stripe);
}

/* Media */
img,
video {
  border-radius: 8px;
}

figure {
  margin: 0 0 1.3em 0;
}

figcaption {
  margin-top: 0.55em;
}

/* Forms: native-first, transparent, calm */
form {
  margin: 0 0 1.6em 0;
}

/* Helps common “label + input” structures without requiring classes */
form > * + * {
  margin-top: 1em;
}

label {
  display: inline-block;
  margin: 0 0 0.35em 0;
  font-family: var(--sans);
  font-size: 0.92em;
  color: var(--muted);
}

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

input,
textarea,
select {
  accent-color: var(--link);
}

:where(
    input:not([type]),
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="url"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="time"],
    input[type="month"],
    input[type="week"],
    textarea,
    select
  ) {
  width: 100%;
  padding: 0.62em 0.72em;
  font-family: var(--sans);
  font-size: 0.98em;

  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;

  transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea {
  min-height: 7em;
  resize: vertical;
}

:where(input, textarea, select)::placeholder {
  color: color-mix(in oklab, var(--fg) 38%, transparent);
}

/* Check/radio: keep native, just align */
input[type="checkbox"],
input[type="radio"] {
  width: 1.05em;
  height: 1.05em;
  vertical-align: middle;
  margin: 0 0.55em 0 0;
}

/* If label wraps control: make it look intentional */
label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  margin: 0.25em 0;
  color: var(--fg);
  font-size: 1em;
}
label:has(> input[type="checkbox"]) > input,
label:has(> input[type="radio"]) > input {
  margin: 0;
}

/* Focus: quiet ring */
:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--link) 55%, transparent);
  outline-offset: 2px;
}

:where(input, textarea, select):focus {
  border-color: color-mix(in oklab, var(--fg) 22%, var(--link));
}

/* Buttons: text-forward, barely-there hover */
button,
input[type="button"],
input[type="submit"],
input[type="reset"] {
  appearance: none;
  -webkit-appearance: none;

  font-family: var(--sans);
  font-size: 0.98em;
  padding: 0.58em 0.95em;

  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;

  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

button:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
input[type="reset"]:hover {
  background: var(--soft);
  border-color: color-mix(in oklab, var(--fg) 18%, transparent);
}

button:active,
input[type="button"]:active,
input[type="submit"]:active,
input[type="reset"]:active {
  background: color-mix(in oklab, var(--fg) 8%, transparent);
}

/* Disabled + validation */
:disabled,
[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

:where(input, textarea, select)[aria-invalid="true"],
:where(input, textarea, select):invalid {
  border-color: color-mix(in oklab, var(--fg) 18%, red);
}

/* Fieldsets: keep minimal (no layout assumptions) */
fieldset {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 1em 1.1em;
  margin: 0;
  min-width: 0;
}

legend {
  padding: 0 0.4em;
  max-width: 100%;
}

/* Print: lean and editorial */
@media print {
  main,
  article,
  body > *:first-child {
    max-width: none;
    padding: 0;
  }

  a {
    color: #0000ff;
    text-decoration: underline;
  }

  table {
    display: table;
    overflow: visible;
  }
}
