/* ==========================================================================
   Boxydot comfort settings (1.14.0, colour added in 1.18.0)

   A visitor's own reading and comfort choices. They are saved only in this browser
   (localStorage `boxydot_comfort`) and applied as data attributes on <html> before
   the first paint (see inc/comfort.php), so nothing flashes.

     data-bxd-size      1 | 2 | 3      bigger text (112.5% / 125% / 150% of the browser size)
     data-bxd-read      1              easier reading: roomier letters, words and lines
     data-bxd-contrast  1              higher contrast text, borders and focus rings
     data-bxd-motion    reduce         calmer screen: animations and transitions off
     data-bxd-touch     1              bigger buttons and controls (44px or more)
     data-bxd-accent    pink | orange | green   the site colour (teal is the default: no attribute)

   Loaded after main.css. Every rule is scoped to those attributes, except the small
   light-mode contrast fix at the top.
   ========================================================================== */

/* ---------- Fix: teal tags on a light background (2.5:1 before, 4.7:1 now) ---------- */
html[data-theme="light"] .bxd-tag--teal { color: var(--accent-text); border-color: rgba(var(--bxd-accent-text-rgb), .55); }

/* ---------- Text size ---------- */
html[data-bxd-size="1"] { font-size: 112.5%; }
html[data-bxd-size="2"] { font-size: 125%; }
html[data-bxd-size="3"] { font-size: 150%; }

/* ---------- Easier reading ---------- */
html[data-bxd-read="1"] {
  --bxd-font: Verdana, Tahoma, "Trebuchet MS", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
html[data-bxd-read="1"] body {
  letter-spacing: .025em;
  word-spacing: .12em;
  line-height: 1.75;
}
html[data-bxd-read="1"] .bxd-prose,
html[data-bxd-read="1"] .bxd-card__notes,
html[data-bxd-read="1"] .bxd-reader__para { line-height: 1.85; }
html[data-bxd-read="1"] .bxd-prose p { max-width: 68ch; }

/* ---------- Higher contrast ---------- */
html[data-bxd-contrast="1"][data-theme="dark"] {
  --text: #FFFFFF;
  --muted: #E8F4FA;
  --faint: #D5E9F3;
  --line: rgba(255, 255, 255, .6);
  --line-soft: rgba(255, 255, 255, .38);
  --accent-text: #7FE3D6;
  --amber-text: #FFD27A;
  /* Darker page (1.18.1): near-black behind white text, cards one step lighter so they still stand out. */
  --bg: #02060B;
  --bg-deep: #000000;
  --field: #000000;
  --header-bg: rgba(2, 6, 11, .96);
  --header-bg-solid: #02060B;
  --surface: #0B1520;
  --surface-solid: #0B1520;
  --chip: rgba(255, 255, 255, .12);
}
html[data-bxd-contrast="1"][data-theme="light"] {
  --text: #0A1420;
  --muted: #1B3347;
  --faint: #2A4358;
  --line: rgba(10, 20, 32, .65);
  --line-soft: rgba(10, 20, 32, .4);
  --accent-text: #0F5C54;
  --amber-text: #5E3E00;
  /* Whiter page (1.18.1): pure white behind near-black text; bars and the footer a barely-there grey, outlined. */
  --bg: #FFFFFF;
  --bg-deep: #F1F3F5;
  --field: #FFFFFF;
  --header-bg: rgba(255, 255, 255, .97);
  --header-bg-solid: #FFFFFF;
  --surface: #FFFFFF;
  --surface-solid: #FFFFFF;
  --chip: rgba(10, 20, 32, .08);
}
html[data-bxd-contrast="1"] :focus-visible {
  outline: 3px solid var(--bxd-amber);
  outline-offset: 3px;
}
html[data-bxd-contrast="1"][data-theme="light"] :focus-visible { outline-color: #0A1420; }
html[data-bxd-contrast="1"] .bxd-tag--teal { color: var(--accent-text); }
html[data-bxd-contrast="1"] a:not([class]) { text-decoration: underline; }

/* ---------- Calmer screen ----------
   Same approach as the system "reduce motion" rule in main.css: durations are
   shortened rather than removed, so scripts that wait for a transition to end
   (story page turns, for example) still finish. */
html[data-bxd-motion="reduce"] { scroll-behavior: auto; }
html[data-bxd-motion="reduce"] *,
html[data-bxd-motion="reduce"] *::before,
html[data-bxd-motion="reduce"] *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
  scroll-behavior: auto !important;
}

/* ---------- Site colour (1.18.0) ----------
   Teal is the default and has no attribute. Each colour sets the same variables main.css uses,
   once for dark (also the default when no theme is set) and once for light, then once more for
   "Stronger contrast". Button colours keep 4.5:1 with the dark text on them; the hover colours
   keep 4.5:1 with white; the text shades keep 4.5:1 or more on their background. */
html[data-bxd-accent="pink"] {
  --bxd-teal: #E85D9C; --bxd-teal-hover: #B8346F;
  --bxd-accent-rgb: 232, 93, 156; --bxd-accent-text-rgb: 176, 48, 106;
  --accent-text: #FF8DBD; --bxd-accent-bright: #FF8DBD; --bxd-accent-pale: #FFD6E8;
}
html[data-bxd-accent="pink"][data-theme="light"] {
  --accent-text: #B0306A; --bxd-accent-bright: #B0306A;
}
html[data-bxd-accent="orange"] {
  --bxd-teal: #EE8A2E; --bxd-teal-hover: #B2530A;
  --bxd-accent-rgb: 238, 138, 46; --bxd-accent-text-rgb: 163, 79, 5;
  --accent-text: #FFA95A; --bxd-accent-bright: #FFA95A; --bxd-accent-pale: #FFE0C2;
}
html[data-bxd-accent="orange"][data-theme="light"] {
  --accent-text: #A34F05; --bxd-accent-bright: #A34F05;
}
html[data-bxd-accent="green"] {
  --bxd-teal: #4DB36E; --bxd-teal-hover: #2B7A45;
  --bxd-accent-rgb: 77, 179, 110; --bxd-accent-text-rgb: 37, 113, 63;
  --accent-text: #6FD18E; --bxd-accent-bright: #6FD18E; --bxd-accent-pale: #CDF2D8;
}
html[data-bxd-accent="green"][data-theme="light"] {
  --accent-text: #25713F; --bxd-accent-bright: #25713F;
}
/* Stronger contrast keeps working with every colour */
html[data-bxd-accent="pink"][data-bxd-contrast="1"][data-theme="dark"]   { --accent-text: #FFC0DA; --bxd-accent-bright: #FFC0DA; }
html[data-bxd-accent="pink"][data-bxd-contrast="1"][data-theme="light"]  { --accent-text: #8A1F52; --bxd-accent-bright: #8A1F52; }
html[data-bxd-accent="orange"][data-bxd-contrast="1"][data-theme="dark"]  { --accent-text: #FFCC94; --bxd-accent-bright: #FFCC94; }
html[data-bxd-accent="orange"][data-bxd-contrast="1"][data-theme="light"] { --accent-text: #7A3A00; --bxd-accent-bright: #7A3A00; }
html[data-bxd-accent="green"][data-bxd-contrast="1"][data-theme="dark"]   { --accent-text: #A6EBBC; --bxd-accent-bright: #A6EBBC; }
html[data-bxd-accent="green"][data-bxd-contrast="1"][data-theme="light"]  { --accent-text: #195A30; --bxd-accent-bright: #195A30; }
/* Selected text and keyboard focus stay readable on every colour */
html[data-bxd-accent] ::selection { background: var(--bxd-teal-hover); color: #fff; }
html[data-bxd-accent][data-theme="light"] :focus-visible { outline-color: var(--accent-text); }

/* ---------- Bigger buttons ---------- */
html[data-bxd-touch="1"] { --bxd-ctl: 3rem; }
html[data-bxd-touch="1"] .bxd-btn,
html[data-bxd-touch="1"] .bxd-iconbtn,
html[data-bxd-touch="1"] .bxd-chip,
html[data-bxd-touch="1"] .bxd-galnav__item,
html[data-bxd-touch="1"] .bxd-linkbtn,
html[data-bxd-touch="1"] .bxd-learn__tile,
html[data-bxd-touch="1"] .bxd-quest__opt,
html[data-bxd-touch="1"] .bxd-ideatype__box,
html[data-bxd-touch="1"] select {
  min-height: 2.75rem;
}
html[data-bxd-touch="1"] .bxd-iconbtn { min-width: 2.75rem; }

/* ==========================================================================
   The settings window
   ========================================================================== */
.bxd-comfort { display: grid; gap: 1.25rem; padding-top: .25rem; }
.bxd-comfort__intro { margin: 0; font-size: .9375rem; color: var(--muted); }
.bxd-comfort fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.bxd-comfort legend { padding: 0; margin: 0 0 .5rem; font-weight: 700; font-size: 1rem; color: var(--text); }

/* Text size buttons (1.17.2): always an even grid (2 x 2, or 4 across when there is room),
   never 3 + 1 or 2 + 1. The window is a size container, so the layout reacts to the real width
   of the window and to the chosen text size (rem grows with "Larger" and "Largest"). */
.bxd-comfort { container-type: inline-size; container-name: bxd-comfort; }
.bxd-sizes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.bxd-sizes label { position: relative; display: block; min-width: 0; }
.bxd-sizes input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.bxd-sizes__box {
  display: grid; min-width: 0; place-items: center; min-height: 3rem; padding: .5rem .5rem;
  border: 2px solid var(--line); border-radius: var(--bxd-radius-sm);
  background: var(--chip); color: var(--text); font-weight: 700; line-height: 1.15; text-align: center;
  white-space: nowrap; overflow-wrap: normal; word-break: normal; hyphens: none;
}
.bxd-sizes input:checked + .bxd-sizes__box { background: var(--bxd-teal); border-color: var(--bxd-teal); color: var(--on-accent); }
.bxd-sizes input:focus-visible + .bxd-sizes__box { outline: 3px solid var(--bxd-amber); outline-offset: 2px; }
/* A gentle step up in the labels, kept small so "Largest" always fits its button. */
.bxd-sizes label:nth-child(1) .bxd-sizes__box { font-size: .9375rem; }
.bxd-sizes label:nth-child(2) .bxd-sizes__box { font-size: 1rem; }
.bxd-sizes label:nth-child(3) .bxd-sizes__box { font-size: 1.0625rem; }
.bxd-sizes label:nth-child(4) .bxd-sizes__box { font-size: 1.125rem; }
@container bxd-comfort (min-width: 28rem) {
  .bxd-sizes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Colour swatches (1.18.0): same even grid as the text sizes (2 x 2, or 4 across when there is room). */
.bxd-swatches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.bxd-swatches label { position: relative; display: block; min-width: 0; }
.bxd-swatches input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.bxd-swatches__box {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .375rem; min-width: 0; min-height: 4.5rem; padding: .625rem .5rem;
  border: 2px solid var(--line); border-radius: var(--bxd-radius-sm);
  background: var(--chip); color: var(--text); font-size: .9375rem; font-weight: 700; line-height: 1.15; text-align: center; white-space: nowrap;
}
/* The dot always shows its own colour, whatever colour is chosen for the site. */
.bxd-swatches__dot { position: relative; display: block; width: 2rem; height: 2rem; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .18); }
.bxd-swatches__dot::after {
  content: ""; position: absolute; left: 50%; top: 46%; width: .5rem; height: .9rem; border: solid #081018; border-width: 0 .2rem .2rem 0;
  transform: translate(-50%, -50%) rotate(45deg); opacity: 0;
}
.bxd-swatches input:checked + .bxd-swatches__box { border-color: var(--text); background: var(--hover); }
.bxd-swatches input:checked + .bxd-swatches__box .bxd-swatches__dot::after { opacity: 1; }
.bxd-swatches input:focus-visible + .bxd-swatches__box { outline: 3px solid var(--bxd-amber); outline-offset: 2px; }
.bxd-swatches label[data-accent="teal"]   { --sw: #2D9F93; }
.bxd-swatches label[data-accent="pink"]   { --sw: #E85D9C; }
.bxd-swatches label[data-accent="orange"] { --sw: #EE8A2E; }
.bxd-swatches label[data-accent="green"]  { --sw: #4DB36E; }
@container bxd-comfort (min-width: 28rem) {
  .bxd-swatches { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.bxd-comfort__row { padding: .75rem 0; border-top: 1px solid var(--line-soft); }
.bxd-comfort__row .bxd-label { font-size: 1rem; }
.bxd-comfort__row .bxd-small { font-size: .875rem; }
.bxd-comfort__foot { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; padding-top: .75rem; border-top: 1px solid var(--line-soft); }
.bxd-comfort__foot p { margin: 0; font-size: .8125rem; color: var(--muted); flex: 1 1 14rem; }
