/* BufferMint Tools — shared minimal styles.
   Colours, font and radius come from assets/brand/tokens.css (the shared brand repo, git submodule
   brand/); change them there. tokens.css also switches them for dark mode. */
:root {
  --bg: var(--bm-bg);
  --fg: var(--bm-fg);
  --heading: var(--bm-heading);
  --muted: var(--bm-muted);
  --line: var(--bm-line);
  --panel: var(--bm-panel);
  --accent: var(--bm-accent);
  --accent-fg: var(--bm-accent-fg);
  --highlight: var(--bm-highlight);
  --danger: var(--bm-danger);
  --ok: var(--bm-ok);
  --radius: var(--bm-radius-md);
  --mono: var(--bm-font-mono);
  --sans: var(--bm-font-sans);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
/* links inside running text must not rely on colour alone (WCAG 1.4.1) */
p a, li a, td a, .content a { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h1, h2, h3 { color: var(--heading); font-weight: 600; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
p { margin: .5rem 0; }
code, kbd, pre, .mono { font-family: var(--mono); font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* layout (header and footer come from the brand repo: assets/brand/chrome.css) */
.wrap { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.wrap.wide { max-width: 1240px; }
.lead { color: var(--muted); margin: 0 0 1.5rem; font-size: var(--bm-text-lg); line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1 1 0; }
.grid { display: grid; gap: 1rem; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stack > * + * { margin-top: .75rem; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem;
}

/* forms */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
label.inline { display: inline-flex; align-items: center; gap: .4rem; margin: 0; color: var(--fg); font-size: .9rem; }
input, select, textarea, button {
  font: inherit; color: inherit;
}
input[type="text"], input[type="number"], input[type="search"], input[type="url"],
input[type="email"], input[type="password"], input[type="date"], input[type="time"],
input[type="datetime-local"], input:not([type]), select, textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .5rem .65rem; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 160px; resize: vertical; font-family: var(--mono); font-size: .9rem; line-height: 1.45; }
input[type="color"] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

button, .btn {
  display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .45rem .85rem; white-space: nowrap; text-decoration: none; color: var(--fg);
}
button:hover, .btn:hover { border-color: var(--muted); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
button.primary:hover, .btn.primary:hover { background: var(--bm-accent-hover); border-color: var(--bm-accent-hover); }
button:disabled { opacity: .5; cursor: not-allowed; }

/* output */
.out {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .75rem; font-family: var(--mono); font-size: .9rem;
  white-space: pre-wrap; word-break: break-word; min-height: 2.5rem; overflow: auto;
}
.error { color: var(--danger); }
.ok { color: var(--ok); }
.stat { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tag {
  display: inline-block; font-size: .75rem; padding: .1rem .5rem;
  border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
}
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
canvas { max-width: 100%; }
.drop {
  border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 2rem 1rem;
  text-align: center; color: var(--muted); cursor: pointer;
}
.drop.over { border-color: var(--accent); color: var(--accent); }

.toast {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: .45rem .9rem; border-radius: var(--radius);
  font-size: .85rem; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* hub */
.search { font-size: 1.05rem; padding: .7rem .9rem; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: 1rem 0 1.5rem; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: .25rem .8rem;
  background: transparent; font-size: .85rem; color: var(--muted);
}
.chip.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tools { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tool {
  display: block; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--fg);
}
.tool:hover { border-color: var(--accent); text-decoration: none; }
.tool b { display: block; font-weight: 600; }
.tool small { color: var(--muted); display: block; margin-top: .15rem; }
.section-title { display: flex; align-items: baseline; gap: .5rem; margin: 2rem 0 .75rem; }
.section-title h2 { margin: 0; }

@media (max-width: 600px) {
  .wrap { padding: 1rem 16px 3rem; }
}

/* page chrome */
.crumbs { color: var(--muted); margin-bottom: .5rem; }
.crumbs a { color: var(--muted); }
.app { margin: 1rem 0 2.5rem; }
.content { max-width: 720px; border-top: 1px solid var(--line); padding-top: 1rem; }
.content h2 { margin-top: 1.5rem; }
.content h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.content p, .content li { color: var(--fg); }
.content ul, .content ol { padding-left: 1.25rem; }
.related { margin-top: 2.5rem; }
.footcats { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 1rem; padding-top: 1.5rem; padding-bottom: 0; }
.footcats a { color: var(--muted); }
.footnote { text-align: center; padding-top: .5rem; padding-bottom: 2rem; }
/* "Made by BufferMint" hand-off to the services: a band on hubs, one line on tool pages */
.made-by { background: var(--bm-bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.made-by .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; padding-top: 1.5rem; padding-bottom: 1.5rem; }
.made-by p { margin: 0; font-size: var(--bm-text-lg); color: var(--heading); }
.made-by-line { color: var(--muted); border-top: 1px solid var(--line); padding-top: 1.25rem; padding-bottom: 0; }
.trust { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin: .6rem 0 0; }
.trust span::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.cat[hidden], .tool[hidden] { display: none; }

/* ---------- polish & responsive ---------- */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
img, video, canvas, svg, iframe { max-width: 100%; }
h1 { font-size: var(--bm-h1); line-height: 1.15; letter-spacing: -.015em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, .btn, .tool, .chip, input, select, textarea { transition: border-color .15s, background-color .15s, box-shadow .15s, transform .1s; }
button:active, .btn:active { transform: translateY(1px); }
.tool:hover { box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 14%, transparent); }
.card { box-shadow: 0 1px 2px rgb(0 0 0 / .03); }

/* segmented control: <div class="seg"><button class="on">A</button><button>B</button></div> */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; max-width: 100%; flex-wrap: wrap; }
.seg > * { border: 0; border-radius: 0; border-right: 1px solid var(--line); background: var(--panel); }
.seg > *:last-child { border-right: 0; }
.seg > .on, .seg > [aria-pressed="true"] { background: var(--fg); color: var(--bg); }

/* wide content that must scroll sideways on small screens instead of the page */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.scroll-x > table { min-width: 480px; }

/* big preview area for canvases/images */
.stage { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: grid; place-items: center; min-height: 220px; overflow: hidden; }
.stage.checker { background-image: conic-gradient(var(--line) 25%, transparent 0 50%, var(--line) 0 75%, transparent 0); background-size: 16px 16px; }

/* light "paper" previews (invoices, worksheets, print layouts): black on white in dark mode too,
   so headings, table heads and muted text inside them don't take the dark theme's light colours */
.paper { color-scheme: light; --fg: #111; --heading: #111; --muted: #52525b; --line: #d4d4d8; --panel: #fff; --bg: #fff; background: #fff; color: #111; }

/* touch devices: comfortable targets, no iOS zoom on focus */
@media (pointer: coarse) {
  button, .btn, select, input[type="text"], input[type="number"], input[type="search"], input[type="url"],
  input[type="email"], input[type="password"], input[type="date"], input[type="time"], input[type="datetime-local"], input:not([type]) { min-height: 44px; }
  input, select, textarea { font-size: 16px; }
  /* .mono/.small and the embed-code box shrink fields below 16px, which makes iOS zoom on focus */
  :is(input, select, textarea):is(.mono, .small), :root details.embed textarea { font-size: 16px; }
  .chip { padding: .45rem .9rem; }
  /* one-line text links get a taller hit area: inline padding grows it without moving the layout */
  .crumbs a, .more-row a, .section-title h2 a { padding: .7rem 0; }
  .footcats { gap: 0 1rem; }
  .footcats a { display: inline-block; padding: .55rem 0; }
  /* checkbox labels, <summary> and sliders are only 16-24px tall on their own */
  label.inline { min-height: 40px; }
  summary { padding-block: .5rem; }
  input[type="range"] { min-height: 32px; }
}
@media (max-width: 600px) {
  .chips { flex-wrap: nowrap; overflow-x: auto; margin-left: -16px; margin-right: -16px; padding: 0 16px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .row > button, .row > .btn { flex: 1 1 auto; justify-content: center; }
  /* ...but not at the expense of a .grow output or field in the same row (a password squeezed to 4 characters a line) */
  .row:has(> .grow) > button, .row:has(> .grow) > .btn { flex: 0 0 auto; }
  .stat { font-size: 1.35rem; }
  .card { padding: .85rem; }
  textarea { min-height: 140px; }
  .tools { grid-template-columns: 1fr; gap: .5rem; }
}
@media print {
  .bm-header, .bm-footer, .made-by, .made-by-line, .footcats, .footnote, .related, .crumbs, .content { display: none !important; }
  body { background: #fff; color: #000; }
}

/* [hidden] must win over layout classes (.row, .grid, .card …) */
[hidden] { display: none !important; }

/* hub: show the first cards per category until searching or expanded */
.cat:not(.open) .tool.more { display: none; }
body.searching .cat .tool.more { display: block; }
.searching .more-row, .cat.open .more-row .show-all { display: none; }
.more-row { margin: .75rem 0 0; display: flex; gap: 1rem; align-items: center; }
.theme { padding: .4rem .55rem; }

/* embeddable widgets: the "Embed this tool" box on tool pages, and the /embed/ pages themselves */
details.embed { margin: 1rem 0 0; border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .85rem; background: var(--panel); }
details.embed summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
details.embed textarea { font-family: var(--mono); font-size: .78rem; margin: .5rem 0; }
body.embedded { background: var(--bg); }
body.embedded main.wrap { padding: .75rem; }
.embed-credit { text-align: center; margin: .75rem 0 0; color: var(--muted); }
