/* ==========================================================================
   dhh5.com — shared stylesheet
   Design goals: fast, readable, accessible, mobile-first, dark-mode aware.
   No framework, no external requests, no build step.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --bg:            #f7f8fa;
  --surface:       #ffffff;
  --surface-alt:   #f1f3f6;
  --border:        #dfe3e8;
  --text:          #1c2024;
  --text-muted:    #5c6570;
  --brand:         #0b6bcb;
  --brand-dark:    #08529c;
  --brand-soft:    #e8f1fb;
  --accent:        #0f9d58;
  --danger:        #c5221f;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg:     0 4px 16px rgba(16, 24, 40, .08);
  --maxw:          880px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #14171a;
    --surface:     #1c2126;
    --surface-alt: #232a30;
    --border:      #333c44;
    --text:        #e6eaee;
    --text-muted:  #9aa5b1;
    --brand:       #5aa9f7;
    --brand-dark:  #8cc4fa;
    --brand-soft:  #1d2b3a;
    --accent:      #5ad18a;
    --danger:      #ff8a80;
    --shadow:      0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg:   0 4px 16px rgba(0, 0, 0, .45);
  }
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

h1, h2, h3, h4 { line-height: 1.25; margin: 1.6em 0 .5em; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); margin-top: 0; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.12rem; }
h4 { font-size: 1rem; }

code, pre, .mono { font-family: var(--mono); }
code {
  background: var(--surface-alt);
  padding: .15em .4em;
  border-radius: 4px;
  font-size: .9em;
}

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

main { flex: 1 0 auto; padding-bottom: 48px; }

/* ---------- Header / nav ---------- */
.site-header {
  background: var(--brand);
  color: #fff;
  padding: 14px 0;
  box-shadow: var(--shadow);
}
.site-header a { color: #fff; }

.nav {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.nav-links {
  display: flex;
  gap: 16px;
  margin-left: auto;
  font-size: .93rem;
  flex-wrap: wrap;
}
@media (max-width: 560px) {
  .nav-links { margin-left: 0; width: 100%; gap: 12px; }
}

/* ---------- Page head ---------- */
.page-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 34px 0 30px;
  text-align: center;
}
.page-head h1 { margin-bottom: .35em; }
.page-head p { margin: 0; color: var(--text-muted); font-size: 1.03rem; }

/* ---------- Breadcrumbs ---------- */
.breadcrumb {
  font-size: .85rem;
  color: var(--text-muted);
  padding: 14px 0 0;
}
.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
}
.breadcrumb li + li::before { content: "›"; margin-right: 6px; color: var(--border); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
label {
  display: block;
  font-weight: 600;
  font-size: .92rem;
  margin-bottom: 6px;
}
input[type="text"],
input[type="number"],
input[type="datetime-local"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
textarea { font-family: var(--mono); font-size: .88rem; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); }

.hint { font-size: .84rem; color: var(--text-muted); margin-top: 6px; }

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: background-color .15s ease, transform .05s ease;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-alt); }
.btn-small { padding: 6px 12px; font-size: .85rem; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Result panel ---------- */
.result {
  background: var(--brand-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-size: 1.2rem;
  font-weight: 700;
  word-break: break-word;
  min-height: 56px;
  display: flex;
  align-items: center;
}
.result.error { background: transparent; border-color: var(--danger); color: var(--danger); font-weight: 600; font-size: 1rem; }
.result-label {
  font-size: .82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.result-block { margin-bottom: 18px; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
th, td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--surface-alt);
  font-weight: 600;
  position: sticky;
  top: 0;
}
tbody tr:hover { background: var(--surface-alt); }
td.num, th.num { text-align: right; font-family: var(--mono); font-size: .88rem; }

/* ---------- FAQ ---------- */
.faq { margin: 0; }
.faq dt { font-weight: 700; margin-top: 16px; }
.faq dd { margin: 4px 0 0; color: var(--text-muted); }

/* ---------- Tool grid ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: box-shadow .15s ease, transform .15s ease;
}
.tool-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.tool-card h3 { margin: 0 0 4px; font-size: 1.02rem; }
.tool-card p { margin: 0; font-size: .89rem; color: var(--text-muted); }
.tool-card a { color: inherit; }
.tool-card a:hover { text-decoration: none; }
.tool-card:hover h3 { color: var(--brand); }

/* ---------- Home search ---------- */
.search-box {
  display: flex;
  gap: 10px;
  margin: 22px 0 8px;
  flex-wrap: wrap;
}
.search-box input { flex: 1 1 240px; }

/* ---------- Color swatch ---------- */
.swatch {
  height: 76px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: 14px;
  background-image:
    linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%),
    linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
.swatch-inner { height: 100%; border-radius: inherit; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 26px 0;
  font-size: .88rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* ---------- Utilities ---------- */
.updated { font-size: .84rem; color: var(--text-muted); font-style: italic; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Floating feedback button ---------- */
.feedback-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  padding: 11px 16px;
  border-radius: 999px;
  font: 600 .9rem/1 var(--font);
  box-shadow: var(--shadow-lg);
  transition: background .15s ease, transform .15s ease;
}
.feedback-fab:hover { background: var(--brand-dark); transform: translateY(-1px); }
.feedback-fab:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 2px; }
.feedback-fab svg { flex: none; }
.feedback-fab__label { display: inline; }
@media (max-width: 520px) {
  .feedback-fab__label { display: none; }
  .feedback-fab { padding: 12px; }
}
