/*
 * Site theme for the free tool pages (copied to /tools/tools.css by scripts/build-tools.ts).
 * Loaded after each page's own <style>: it re-points the page's tokens at the site palette
 * (src/styles/global.css :root) and styles the shared header, intro band and footer.
 * Site classes are prefixed `lb-` so they never collide with a tool's own classes.
 */

/* ---------- Tokens: same palette as the main site, light only (like the site) ---------- */
:root,
:root:not([data-theme='light']),
:root[data-theme='dark'] {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --muted: #526075;
  --line: #dbe3ee;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #dbeafe;
  --danger: #b42318;
  --focus: #38bdf8;
  --stage: #eaf0f8;

  --lb-night: #070f1e;
  --lb-brand-deep: #0a1f3d;
  --lb-accent-deep: #1d4ed8;
  --lb-highlight: #38bdf8;
  --lb-head: 'Anuphan', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --lb-mono: 'JetBrains Mono', 'IBM Plex Sans Thai', ui-monospace, Menlo, Consolas, monospace;
}

body {
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.wrap {
  max-width: 1160px;
  padding: 0 24px;
}

/* Tool controls: rounder, site-style primary buttons */
.btn {
  border-radius: 999px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn.primary:hover:not(:disabled) {
  background: var(--lb-accent-deep);
  border-color: var(--lb-accent-deep);
  transform: translateY(-1px);
}

.panel {
  border-color: var(--line);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.05), 0 12px 32px -16px rgb(15 23 42 / 0.16);
}

.stage {
  border: 1px solid var(--line);
}

.panel {
  padding-top: 8px;
}

legend {
  font-family: var(--lb-head);
}

/* Native controls themed like the site's fields */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23526075' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  cursor: pointer;
}

input[type='file'] {
  max-width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--muted);
}

input[type='file']::file-selector-button {
  margin-right: 12px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 500 14px/1.2 'IBM Plex Sans Thai', system-ui, sans-serif;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

input[type='file']::file-selector-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Header (matches .header on the site) ---------- */
.lb-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgb(7 15 30 / 0.97);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgb(241 245 249 / 0.08);
}

.lb-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 72px;
}

.lb-header__brand,
.lb-footer__brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.lb-header__nav {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 15px;
  font-weight: 500;
}

.lb-header__nav > a:not(.lb-btn) {
  color: rgb(241 245 249 / 0.72);
  text-decoration: none;
  transition: color 0.15s;
}

.lb-header__nav > a:not(.lb-btn):hover,
.lb-header__nav > a[aria-current='page'] {
  color: #fff;
}

/* ---------- Logo (matches .logo on the site) ---------- */
.lb-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.lb-logo__mark {
  display: block;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  margin-top: 4px;
}

.lb-logo__layer {
  fill: none;
  stroke: #3b82f6;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lb-logo__layer--back {
  stroke-opacity: 0.45;
}

.lb-logo__lit {
  filter: drop-shadow(0 0 2.5px rgb(56 189 248 / 0.9));
}

.lb-logo__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.lb-logo__name {
  font: 700 20px/1.2 var(--lb-head);
  letter-spacing: -0.02em;
  color: #fff;
}

.lb-logo__sub {
  font: 500 11px/1.3 'IBM Plex Sans Thai', system-ui, sans-serif;
  letter-spacing: 0.01em;
  color: rgb(241 245 249 / 0.6);
}

/* ---------- Buttons ---------- */
.lb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 24px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  background: var(--accent);
  color: #fff;
  font: 600 15px/1 'IBM Plex Sans Thai', system-ui, sans-serif;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, transform 0.15s;
}

.lb-btn:hover {
  background: var(--lb-accent-deep);
  transform: translateY(-1px);
}

.lb-btn--sm {
  height: 40px;
  padding: 0 18px;
  font-size: 14px;
}

.lb-btn--ghost {
  background: transparent;
  border-color: rgb(241 245 249 / 0.35);
}

.lb-btn--ghost:hover {
  background: rgb(241 245 249 / 0.08);
  border-color: rgb(241 245 249 / 0.6);
}

.lb-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font: 600 13px/1.4 'IBM Plex Sans Thai', system-ui, sans-serif;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.lb-eyebrow::before {
  content: '';
  width: 18px;
  height: 2px;
  background: currentColor;
}

.lb-eyebrow--light {
  color: var(--lb-highlight);
}

/* ---------- Intro band (like the privacy page header) ---------- */
.lb-intro {
  position: relative;
  margin-bottom: 28px;
  background: #eaf0f8;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.lb-intro::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgb(15 47 92 / 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgb(15 47 92 / 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: linear-gradient(90deg, transparent 30%, #000 100%);
  mask-image: linear-gradient(90deg, transparent 30%, #000 100%);
  pointer-events: none;
}

.lb-intro > .wrap {
  position: relative;
  padding-top: 28px;
  padding-bottom: 32px;
}

.lb-intro .intro {
  padding: 0;
}

.lb-intro .intro h1 {
  font-family: var(--lb-head);
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: -0.01em;
  color: var(--ink);
}

.lb-intro .intro p:not(.private):not(.lb-eyebrow) {
  font-size: 17px;
}

.lb-intro .private {
  border: 1px solid rgb(37 99 235 / 0.2);
}

.lb-crumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  font-size: 14px;
  color: var(--muted);
}

.lb-crumb a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}

.lb-crumb a:hover {
  text-decoration: underline;
}

/* ---------- Share this tool ---------- */
.lb-share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.lb-share__label {
  margin-right: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.lb-share__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 500 14px/1 'IBM Plex Sans Thai', system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.lb-share__btn[hidden] {
  display: none;
}

.lb-share__btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.lb-share__btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lb-share__btn--line svg {
  color: #06c755;
}

.lb-share__btn--fb svg {
  color: #1877f2;
}

.lb-share__btn.is-done {
  border-color: #16a34a;
  background: #dcfce7;
  color: #166534;
}

/* ---------- More tools ---------- */
.lb-more {
  padding: 56px 0 64px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.lb-more__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  margin-bottom: 20px;
}

.lb-more__head h2 {
  margin: 0;
  font: 700 26px/1.3 var(--lb-head);
}

.lb-more__head a {
  font-weight: 600;
  text-decoration: none;
}

.lb-more__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lb-more__grid a {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.lb-more__grid a:hover {
  border-color: rgb(37 99 235 / 0.45);
  transform: translateY(-2px);
  box-shadow: 0 16px 32px -20px rgb(15 23 42 / 0.35);
}

.lb-more__grid b {
  font: 600 17px/1.4 var(--lb-head);
}

.lb-more__grid span {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.6;
}

.lb-more__grid i {
  margin-top: auto;
  padding-top: 8px;
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
  font-size: 14px;
}

/* ---------- Footer ---------- */
.lb-footer {
  background: var(--lb-night);
  color: rgb(241 245 249 / 0.72);
}

.lb-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px 48px;
  padding-top: 56px;
  padding-bottom: 48px;
}

.lb-cta__copy {
  max-width: 620px;
}

.lb-cta h2 {
  margin: 0 0 10px;
  font: 700 clamp(24px, 3vw, 32px)/1.3 var(--lb-head);
  color: #fff;
}

.lb-cta p:not(.lb-eyebrow) {
  margin: 0;
  font-size: 16px;
}

.lb-cta__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.lb-footer__bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding-top: 24px;
  padding-bottom: 32px;
  border-top: 1px solid rgb(241 245 249 / 0.12);
  font-size: 14px;
}

.lb-footer__links {
  display: flex;
  gap: 10px;
}

.lb-footer a:not(.lb-btn) {
  color: inherit;
  text-decoration: none;
}

.lb-footer__links a:hover {
  color: #fff;
}

/* ---------- Responsive ---------- */
@media (max-width: 899px) {
  .wrap {
    padding: 0 16px;
  }

  .lb-more__grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .lb-header__inner {
    height: 64px;
  }

  .lb-header__nav > a:not(.lb-btn) {
    display: none;
  }

  .lb-intro > .wrap {
    padding-top: 20px;
    padding-bottom: 24px;
  }

  .lb-cta__actions,
  .lb-cta__actions .lb-btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lb-btn,
  .lb-more__grid a,
  .btn {
    transition: none;
  }
}

@media print {
  .lb-header,
  .lb-intro,
  .lb-more,
  .lb-footer {
    display: none !important;
  }
}
