/* ============================================================
   Fable Image Tools — shared stylesheet
   A storybook look: warm paper, ink lines, terracotta & sage.
   ============================================================ */

:root {
  --paper: #f7f1e3;
  --paper-bright: #fdfaf1;
  --paper-dim: #efe6d0;
  --ink: #2f2a24;
  --ink-soft: #59503f;
  --ink-faint: #6f6553; /* passes WCAG AA (≥4.5:1) on all paper tones */
  --line: #d9cdb2;
  --accent: #b4552d;      /* terracotta */
  --accent-dark: #8f4223;
  --sage: #5c7c65;
  --sage-dark: #48634f;
  --gold: #c9a227;
  --danger: #a03c2e;
  --radius: 14px;
  --shadow: 0 2px 0 rgba(47, 42, 36, 0.9), 0 10px 24px rgba(47, 42, 36, 0.12);
  --shadow-soft: 0 6px 18px rgba(47, 42, 36, 0.1);
  --font-display: "Fraunces", "Georgia", serif;
  --font-body: "Crimson Pro", "Georgia", serif;
}

* { box-sizing: border-box; }

/* The hidden attribute must win over any display rule below. */
[hidden] { display: none !important; }

/* Keyboard focus must always be visible. */
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.dropzone:focus-within {
  border-color: var(--accent);
  background: #fdf6e7;
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

html { color-scheme: light; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 20% -10%, rgba(201, 162, 39, 0.08), transparent 55%),
    radial-gradient(ellipse at 90% 0%, rgba(180, 85, 45, 0.06), transparent 45%),
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(47, 42, 36, 0.012) 2px 4px);
  min-height: 100vh;
}

img { max-width: 100%; }

/* ---------- layout ---------- */

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 2rem;
  align-items: start;
  margin: 2rem auto 3rem;
}

@media (max-width: 960px) {
  .tool-layout { grid-template-columns: minmax(0, 1fr); }
}

.tool-side { display: grid; gap: 1.5rem; align-content: start; }

/* ---------- header & nav ---------- */

.site-header {
  border-bottom: 2px solid var(--ink);
  background: var(--paper-bright);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.brand .brand-logo {
  width: 2rem;
  height: 2rem;
  border-radius: 9px;
  box-shadow: 0 2px 0 rgba(47, 42, 36, 0.55);
}

.site-nav { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.site-nav a {
  font-family: var(--font-display);
  font-size: 0.98rem;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border: 2px solid transparent;
  border-radius: 999px;
}

.site-nav a:hover { color: var(--ink); border-color: var(--line); }

.site-nav a.active {
  color: var(--paper-bright);
  background: var(--ink);
  border-color: var(--ink);
}

/* ---------- hero / page intro ---------- */

.page-intro { text-align: center; margin: 2.5rem auto 1.5rem; max-width: 46rem; }

.page-intro h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.12;
  margin: 0 0 0.6rem;
}

.page-intro h1 em { color: var(--accent); font-style: italic; }

.page-intro p { margin: 0 auto; color: var(--ink-soft); font-size: 1.18rem; }

.flourish {
  display: block;
  width: 190px;
  margin: 1.1rem auto 0;
  color: var(--accent);
}

/* ---------- cards ---------- */

.card {
  background: var(--paper-bright);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.card h2, .card h3 {
  font-family: var(--font-display);
  margin-top: 0;
}

.card--plain { box-shadow: var(--shadow-soft); border-color: var(--line); }

/* ---------- home tool cards ---------- */

.tool-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0 3rem;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tool-card:hover {
  transform: translateY(-4px) rotate(-0.4deg);
  box-shadow: 0 3px 0 rgba(47, 42, 36, 0.9), 0 16px 30px rgba(47, 42, 36, 0.18);
}

.tool-card .tool-emblem {
  width: 3.2rem;
  height: 3.2rem;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-dim);
  box-shadow: 0 2px 0 rgba(47, 42, 36, 0.9);
}

.tool-card h2 { margin: 0.4rem 0 0; font-size: 1.45rem; }

.tool-card p { margin: 0; color: var(--ink-soft); }

.tool-card .tool-go {
  margin-top: auto;
  font-family: var(--font-display);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- buttons & inputs ---------- */

.btn {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--paper-bright);
  background: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.6rem 1.4rem;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(47, 42, 36, 0.55);
  transition: transform 0.1s ease, background 0.15s ease;
}

a.btn { display: inline-block; text-decoration: none; }

.btn:hover:not(:disabled) { background: #45403a; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--accent { background: var(--accent); border-color: var(--accent-dark); }
.btn--accent:hover:not(:disabled) { background: var(--accent-dark); }

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
  box-shadow: none;
}
.btn--ghost:hover:not(:disabled) { background: var(--paper-dim); }

.btn--small { font-size: 0.9rem; padding: 0.35rem 0.95rem; }

label { font-family: var(--font-display); font-size: 0.95rem; font-weight: 600; }

select, input[type="number"], input[type="text"] {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper-bright);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  max-width: 100%;
}

input[type="range"] { accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }

.field { display: grid; gap: 0.3rem; }

.options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem 1.6rem;
  align-items: end;
  margin: 1.1rem 0;
}

.check-row { display: flex; align-items: center; gap: 0.45rem; font-family: var(--font-display); font-size: 0.95rem; font-weight: 600; }

/* ---------- dropzone ---------- */

.dropzone {
  position: relative;
  border: 2px dashed var(--ink-faint);
  border-radius: var(--radius);
  background: var(--paper-bright);
  padding: 2.4rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: #fdf6e7;
}

.dropzone .dz-icon { font-size: 2.2rem; display: block; margin-bottom: 0.4rem; }

.dropzone .dz-title { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; margin: 0; }

.dropzone .dz-hint { color: var(--ink-faint); margin: 0.35rem 0 0; font-size: 1rem; }

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ---------- file list & results ---------- */

.file-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.5rem; }

.file-list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--paper-dim);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-size: 1rem;
}

.file-list .file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.file-list .file-size { color: var(--ink-faint); white-space: nowrap; }

.file-list .file-remove {
  border: none;
  background: none;
  color: var(--danger);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1.2rem;
  margin-top: 1.2rem;
}

.result-card {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper-bright);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.result-card .result-thumb {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background:
    repeating-conic-gradient(#e8e0cd 0% 25%, #f6efdd 0% 50%) 0 0 / 22px 22px;
  border-bottom: 2px solid var(--ink);
  overflow: hidden;
}

.result-card .result-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }

.result-card .result-body { padding: 0.7rem 0.85rem 0.9rem; display: grid; gap: 0.45rem; }

.result-card .result-name { font-size: 0.95rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.result-card .result-meta { font-size: 0.9rem; color: var(--ink-soft); }

.result-meta .savings { color: var(--sage-dark); font-weight: 600; }
.result-meta .growth { color: var(--danger); }

.result-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 1.3rem; }

/* ---------- progress ---------- */

.progress {
  height: 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper-dim);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 0.2s ease;
}

.status-line { font-size: 1rem; color: var(--ink-soft); margin: 0.5rem 0 0; min-height: 1.4em; }

/* ---------- ads ---------- */

.ad-slot { display: block; margin: 1.4rem auto; text-align: center; min-height: 90px; }

.ad-slot--banner { max-width: 970px; }
.ad-slot--box { min-height: 250px; }
.ad-slot--footer { max-width: 970px; margin-top: 2.5rem; }

.ad-ph {
  display: grid;
  place-items: center;
  gap: 0.15rem;
  min-height: inherit;
  border: 2px dashed var(--line);
  border-radius: 10px;
  background: repeating-linear-gradient(-45deg, transparent 0 14px, rgba(47, 42, 36, 0.025) 14px 28px);
  color: var(--ink-faint);
  padding: 1rem;
}

.ad-ph span { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.8rem; }

.ad-ph small { font-size: 0.78rem; }

/* Sticky bottom ad bar */
.ad-sticky {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: var(--paper-bright);
  border-top: 2px solid var(--ink);
  box-shadow: 0 -6px 18px rgba(47, 42, 36, 0.15);
  max-height: 108px;
  overflow: hidden;
}

/* Keep toasts above the sticky ad bar (also avoids overlapping a served ad). */
body.has-ad-sticky #toast-root { bottom: calc(110px + 1rem); }

.ad-slot--sticky {
  max-width: 970px;
  margin: 0 auto;
  min-height: 90px;
  padding: 0.35rem 2.6rem 0.35rem 0.5rem;
}

.ad-slot--sticky .ad-ph { min-height: 78px; }

.ad-sticky-close {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  width: 1.8rem;
  height: 1.8rem;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-dim);
  color: var(--ink);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

/* ---------- notes, tips, prose ---------- */

.tip-list { margin: 0.6rem 0 0; padding-left: 1.2rem; }
.tip-list li { margin-bottom: 0.45rem; font-size: 1.02rem; }

.small-note { font-size: 0.95rem; color: var(--ink-faint); }

.prose { max-width: 46rem; margin: 0 auto; }
.prose h2 { font-family: var(--font-display); margin-top: 2rem; }

.badge-row { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; margin-top: 1.2rem; }

.badge {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper-bright);
  padding: 0.25rem 0.8rem;
  box-shadow: 0 2px 0 rgba(47, 42, 36, 0.5);
}

/* ---------- toast ---------- */

#toast-root {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 0.5rem;
  z-index: 100;
  width: min(92vw, 26rem);
}

.toast {
  font-family: var(--font-display);
  font-size: 0.95rem;
  background: var(--ink);
  color: var(--paper-bright);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  box-shadow: 0 8px 20px rgba(47, 42, 36, 0.35);
  animation: toast-in 0.2s ease;
  text-align: center;
}

.toast--error { background: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 2px solid var(--ink);
  background: var(--paper-bright);
  margin-top: 2rem;
}

.site-footer .wrap {
  padding-top: 1.6rem;
  padding-bottom: 1.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  font-size: 1rem;
  color: var(--ink-soft);
}

.site-footer nav { display: flex; gap: 1.1rem; flex-wrap: wrap; }

.site-footer a { color: var(--ink-soft); }
.site-footer a:hover { color: var(--ink); }

.family-line {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.family-line a { font-weight: 600; }

.lang-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-basis: 100%;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
}

.lang-switch label { font-size: 0.92rem; }

.lang-switch select { font-size: 0.95rem; padding: 0.25rem 0.5rem; }

/* SEO copy blocks (how-to + FAQ) */
.seo-copy { margin: 2.5rem auto; }

.seo-copy h3 {
  font-family: var(--font-display);
  font-size: 1.12rem;
  margin: 1.3rem 0 0.25rem;
}

.seo-copy h3 + p { margin-top: 0; }

.seo-copy ol li { margin-bottom: 0.4rem; }

.more-tools { margin-top: 1.6rem; color: var(--ink-soft); }

/* ---------- misc ---------- */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

::selection { background: var(--gold); color: var(--ink); }
