/* ==========================================================================
   WebToolz — Tool page styles
   Loaded only on /tools/*.html. Section 1 is the shared chrome every tool
   page uses; the sections after it are specific to individual tools.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Shared tool-page chrome
   -------------------------------------------------------------------------- */
.container > .breadcrumb { padding-top: var(--space-5); }

.tool-hero {
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(ellipse 60% 100% at 15% 0%, var(--brand-soft), transparent 70%),
    var(--bg);
}
.tool-hero-icon {
  display: grid;
  place-items: center;
  width: 56px; height: 56px;
  border-radius: var(--radius-lg);
  background: var(--brand-soft);
  color: var(--brand-strong);
  border: 1px solid var(--brand-border);
  margin-bottom: var(--space-4);
}
.tool-hero-icon svg { width: 28px; height: 28px; }
.tool-hero-cat { margin-bottom: var(--space-3); }
.tool-hero h1 { font-size: var(--text-4xl); margin-bottom: var(--space-3); }
.tool-hero-intro { font-size: var(--text-lg); max-width: 68ch; margin-bottom: var(--space-4); }

.tool-body { padding-top: var(--space-7); }

/* Two-column layout: controls on the left, output on the right. */
.tool-split {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--space-5);
  align-items: start;
}
.tool-split-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .tool-split, .tool-split-even { grid-template-columns: minmax(0, 1fr); }
}

.tool-notes-title, .related-title { font-size: var(--text-xl); margin-bottom: var(--space-4); }
.tool-notes { font-size: var(--text-sm); max-width: 74ch; }
.tool-notes li::marker { color: var(--brand); }

.output-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.output-head .panel-title { margin-bottom: 0; }

.empty-state {
  display: grid;
  place-items: center;
  gap: var(--space-2);
  text-align: center;
  min-height: 12rem;
  color: var(--text-subtle);
  font-size: var(--text-sm);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-6) var(--space-4);
}

/* Range control with a live value readout */
.range-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.range-row input[type='range'] { flex: 1; }
.range-value {
  flex: none;
  min-width: 4.5rem;
  text-align: right;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--brand-strong);
}

/* Checkbox / radio clusters */
.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
}

/* Reusable file list for the PDF and image tools */
.file-list { list-style: none; margin: var(--space-4) 0 0; padding: 0; }
.file-list li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  margin: 0 0 var(--space-2);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.file-list li.is-dragging { opacity: 0.45; }
.file-list li.is-drop-target { border-color: var(--brand); border-style: dashed; }
.file-thumb {
  width: 44px; height: 44px;
  flex: none;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  object-fit: cover;
  display: grid;
  place-items: center;
  color: var(--text-subtle);
  font-size: var(--text-xs);
  font-weight: 700;
  overflow: hidden;
}
.file-meta { flex: 1; min-width: 0; }
.file-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-sub { display: block; font-size: var(--text-xs); color: var(--text-subtle); }
.file-actions { display: flex; gap: var(--space-1); flex: none; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn svg { width: 15px; height: 15px; }
.drag-handle { cursor: grab; }

/* --------------------------------------------------------------------------
   2. Contact page
   -------------------------------------------------------------------------- */
.contact-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: var(--space-5);
  align-items: start;
}
@media (max-width: 860px) { .contact-layout { grid-template-columns: 1fr; } }
.contact-side .panel + .panel,
.contact-side .alert { margin-top: var(--space-4); }
.contact-email { font-family: var(--font-mono); font-size: var(--text-base); font-weight: 600; }
.contact-note { font-size: var(--text-sm); }
.contact-list { font-size: var(--text-sm); padding-left: 1.1rem; }
.error-help { margin-top: var(--space-6); font-size: var(--text-sm); }

/* --------------------------------------------------------------------------
   3. Lorem Ipsum
   -------------------------------------------------------------------------- */
#lorem-output { min-height: 16rem; }
#lorem-output p { color: var(--text); margin-bottom: var(--space-4); }
#lorem-output p:last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   4. Password generator
   -------------------------------------------------------------------------- */
.pw-output {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  min-height: 4.25rem;
}
.pw-value {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
  word-break: break-all;
  line-height: 1.4;
  color: var(--text);
}
.pw-meter { margin-top: var(--space-4); }
.pw-meter-track {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-2);
}
.pw-meter-seg {
  flex: 1;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  transition: background var(--transition);
}
.pw-meter-seg.on-1 { background: #dc2626; border-color: #dc2626; }
.pw-meter-seg.on-2 { background: #f59e0b; border-color: #f59e0b; }
.pw-meter-seg.on-3 { background: #eab308; border-color: #eab308; }
.pw-meter-seg.on-4 { background: #10b981; border-color: #10b981; }
.pw-meter-label {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-sm);
}
.pw-meter-label strong { font-family: var(--font-heading); }
.pw-history { margin-top: var(--space-4); }
.pw-history li { font-family: var(--font-mono); font-size: var(--text-xs); }

/* --------------------------------------------------------------------------
   5. QR code
   -------------------------------------------------------------------------- */
.qr-stage {
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 20rem;
}
.qr-stage canvas, .qr-stage svg {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

/* --------------------------------------------------------------------------
   6. Favicon generator
   -------------------------------------------------------------------------- */
.favicon-source {
  display: grid;
  place-items: center;
  width: 128px; height: 128px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-inset);
  overflow: hidden;
}
.favicon-source canvas, .favicon-source img { width: 100%; height: 100%; object-fit: cover; }
.favicon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: var(--space-3);
}
.favicon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}
.favicon-item canvas {
  image-rendering: pixelated;
  border-radius: var(--radius-xs);
  background:
    conic-gradient(from 45deg, var(--border) 0 25%, transparent 0 50%,
                   var(--border) 0 75%, transparent 0) 0 0/12px 12px;
}
.favicon-item small { font-size: var(--text-xs); color: var(--text-subtle); font-weight: 600; }

/* --------------------------------------------------------------------------
   7. Unit / Roman converters
   -------------------------------------------------------------------------- */
.convert-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-3);
  align-items: end;
}
@media (max-width: 620px) {
  .convert-row { grid-template-columns: 1fr; }
  .swap-btn { justify-self: center; }
}
.swap-btn {
  flex: none;
  width: 42px; height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--brand-strong);
  cursor: pointer;
  margin-bottom: 2px;
  transition: transform var(--transition), background var(--transition);
}
.swap-btn:hover { background: var(--brand-soft); transform: rotate(180deg); }
.swap-btn svg { width: 18px; height: 18px; }
.convert-readout {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--brand-strong);
  word-break: break-word;
}
.roman-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.roman-part {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.roman-part b { font-family: var(--font-mono); font-size: var(--text-lg); color: var(--brand-strong); }
.roman-part small { font-size: var(--text-xs); color: var(--text-subtle); }

/* --------------------------------------------------------------------------
   8. Image tools (converter, base64, compressor, cropper)
   -------------------------------------------------------------------------- */
.img-stage {
  display: grid;
  place-items: center;
  background:
    conic-gradient(from 45deg, var(--bg-inset) 0 25%, transparent 0 50%,
                   var(--bg-inset) 0 75%, transparent 0) 0 0/20px 20px,
    var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  min-height: 18rem;
  overflow: hidden;
}
.img-stage img, .img-stage canvas { max-width: 100%; max-height: 26rem; object-fit: contain; }

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}
.compare-cell {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
}
.compare-cell b { display: block; font-family: var(--font-heading); font-size: var(--text-lg); }
.compare-cell small { font-size: var(--text-xs); color: var(--text-subtle); }
.saving-good { color: var(--success); }
.saving-bad { color: var(--danger); }

/* Cropper */
.cropper-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  touch-action: none;
  user-select: none;
}
.cropper-stage img { max-width: 100%; display: block; }
.cropper-shade {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.crop-box {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  cursor: move;
  box-sizing: border-box;
}
.crop-box::before,
.crop-box::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255,255,255,.45) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.45) 1px, transparent 1px);
  background-size: 33.333% 33.333%;
}
.crop-handle {
  position: absolute;
  width: 14px; height: 14px;
  background: #fff;
  border: 2px solid var(--emerald-600);
  border-radius: 3px;
  z-index: 2;
}
.crop-handle[data-dir='nw'] { left: -7px;  top: -7px;    cursor: nwse-resize; }
.crop-handle[data-dir='ne'] { right: -7px; top: -7px;    cursor: nesw-resize; }
.crop-handle[data-dir='sw'] { left: -7px;  bottom: -7px; cursor: nesw-resize; }
.crop-handle[data-dir='se'] { right: -7px; bottom: -7px; cursor: nwse-resize; }

/* --------------------------------------------------------------------------
   9. Calculators
   -------------------------------------------------------------------------- */
.bmi-scale {
  position: relative;
  height: 14px;
  border-radius: var(--radius-full);
  margin: var(--space-5) 0 var(--space-4);
  background: linear-gradient(90deg,
    #60a5fa 0 18%, #10b981 18% 42%, #fbbf24 42% 62%, #f97316 62% 80%, #ef4444 80% 100%);
}
.bmi-marker {
  position: absolute;
  top: -7px;
  width: 4px; height: 28px;
  border-radius: 2px;
  background: var(--text);
  transform: translateX(-2px);
  transition: left 300ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
.bmi-scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-subtle);
}

.amort-summary { margin-bottom: var(--space-4); }
.donut-wrap { display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex: none; }
.donut-legend { list-style: none; padding: 0; margin: 0; font-size: var(--text-sm); }
.donut-legend li { display: flex; align-items: center; gap: var(--space-2); }
.donut-key { width: 12px; height: 12px; border-radius: 3px; flex: none; }

.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}
@media (max-width: 560px) { .countdown-grid { grid-template-columns: repeat(2, 1fr); } }
.cd-unit {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-3);
  text-align: center;
}
.cd-value {
  display: block;
  font-family: var(--font-heading);
  font-size: clamp(2rem, 7vw, 3.25rem);
  font-weight: 800;
  line-height: 1;
  color: var(--brand-strong);
  font-variant-numeric: tabular-nums;
}
.cd-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
  margin-top: var(--space-2);
}
.cd-done {
  text-align: center;
  padding: var(--space-7);
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  color: var(--brand-strong);
}

/* --------------------------------------------------------------------------
   10. Stopwatch / timer / Pomodoro
   -------------------------------------------------------------------------- */
.clock-display {
  font-family: var(--font-heading);
  font-size: clamp(2.75rem, 12vw, 5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  line-height: 1.05;
  color: var(--text);
}
.clock-display .ms { font-size: 0.45em; color: var(--text-subtle); }
.clock-sub {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-subtle);
  margin-top: var(--space-2);
}
.clock-ring { display: block; margin: 0 auto var(--space-4); width: 220px; height: 220px; }
.clock-ring circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.clock-ring .track { stroke: var(--bg-inset); }
.clock-ring .bar {
  stroke: var(--brand);
  transition: stroke-dashoffset 250ms linear;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}
.clock-ring.is-break .bar { stroke: var(--accent); }
.lap-list { list-style: none; padding: 0; margin: 0; max-height: 18rem; overflow-y: auto; }
.lap-list li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
  margin: 0;
}
.lap-list li.is-best { color: var(--success); font-weight: 700; }
.lap-list li.is-worst { color: var(--danger); }
.timer-presets { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* --------------------------------------------------------------------------
   11. Typing test
   -------------------------------------------------------------------------- */
.typing-passage {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  line-height: 2;
  letter-spacing: 0.01em;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  max-height: 16rem;
  overflow-y: auto;
  color: var(--text-subtle);
  word-break: break-word;
}
.typing-passage .ch-ok { color: var(--success); }
.typing-passage .ch-bad {
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: 2px;
}
.typing-passage .ch-cur {
  background: var(--brand);
  color: var(--brand-contrast);
  border-radius: 2px;
  animation: cur-pulse 1s ease-in-out infinite;
}
@keyframes cur-pulse { 50% { opacity: 0.55; } }
.typing-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.typing-shell { position: relative; }
.typing-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  border-radius: var(--radius-md);
  font-weight: 600;
  color: var(--text-muted);
  cursor: text;
  text-align: center;
  padding: var(--space-4);
}
.typing-overlay[hidden] { display: none; }

/* --------------------------------------------------------------------------
   12. Coin flip & spinner
   -------------------------------------------------------------------------- */
.coin-stage { display: grid; place-items: center; min-height: 15rem; perspective: 1000px; }
.coin {
  width: 140px; height: 140px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 100ms linear;
}
.coin.is-flipping { animation: coin-spin 1.5s cubic-bezier(0.3, 0, 0.2, 1) forwards; }
@keyframes coin-spin {
  0%   { transform: rotateY(0) translateY(0); }
  45%  { transform: rotateY(900deg) translateY(-90px); }
  100% { transform: rotateY(1800deg) translateY(0); }
}
.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: #4a2c02;
  backface-visibility: hidden;
  box-shadow: inset 0 -6px 14px rgba(0, 0, 0, 0.25), var(--shadow-lg);
  background: radial-gradient(circle at 32% 28%, #fde68a, #f59e0b 62%, #b45309);
  border: 5px solid #d97706;
}
.coin-face.back { transform: rotateY(180deg); }

.wheel-stage { position: relative; display: grid; place-items: center; }
.wheel { width: min(340px, 90%); height: auto; }
.wheel-svg { transition: transform 4.4s cubic-bezier(0.15, 0.85, 0.2, 1); }
.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-top: 24px solid var(--text);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
  z-index: 2;
}
.result-banner {
  text-align: center;
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--brand-strong);
  min-height: 2.2em;
  display: grid;
  place-items: center;
  word-break: break-word;
}
.result-banner.is-new { animation: pop 420ms cubic-bezier(0.2, 0.9, 0.3, 1.4); }
@keyframes pop {
  0%   { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.tally { display: flex; justify-content: center; gap: var(--space-5); font-size: var(--text-sm); }

/* --------------------------------------------------------------------------
   13. PDF tools
   -------------------------------------------------------------------------- */
.pdf-page-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--space-3);
}
.pdf-page-preview label {
  display: block;
  margin: 0;
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-1);
  background: var(--bg-inset);
  text-align: center;
  font-size: var(--text-xs);
  transition: border-color var(--transition);
}
.pdf-page-preview label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.pdf-page-preview canvas { width: 100%; height: auto; border-radius: var(--radius-xs); background: #fff; }
.pdf-page-preview input { position: absolute; opacity: 0; }

.watermark-preview {
  position: relative;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  aspect-ratio: 1 / 1.414;
  width: 100%;
  max-width: 320px;
  margin-inline: auto;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.watermark-preview .wm-lines {
  position: absolute;
  inset: 8%;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.watermark-preview .wm-lines span {
  height: 5px;
  border-radius: 2px;
  background: #e5e5e5;
}
.watermark-preview .wm-lines span:nth-child(4n) { width: 62%; }
.watermark-preview .wm-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-heading);
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
}
.watermark-preview .wm-num {
  position: absolute;
  left: 0; right: 0;
  text-align: center;
  font-size: 10px;
  color: #666;
}
