/* ==========================================================================
   Page-specific styles — hero, home sections, tool template, static shells.
   ========================================================================== */

/* ---- Hero ---- */
.hero {
  padding-block: var(--space-3xl) var(--space-2xl);
  text-align: center;
}

.hero__trust {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.hero h1 {
  max-width: 18ch;
  margin-inline: auto;
}

.hero__lead {
  max-width: 56ch;
  margin: var(--space-md) auto 0;
  font-size: var(--fs-md);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.hero__note {
  margin-top: var(--space-md);
  font-size: var(--fs-xs);
}

/* ---- Breadcrumb + H1 block on tool pages ---- */
.page-intro {
  max-width: 72ch;
  margin-bottom: var(--space-lg);
}

.page-intro h1 {
  margin-bottom: var(--space-xs);
}

/* ---- Tool page content sections ---- */
.tool-content h2 {
  font-size: var(--fs-xl);
}

/* ---- Workspace state machine (Phase 02 shared engine) ----
   Visibility is driven entirely by [data-workspace-state] on the
   workspace-shell root; the UI layer only ever sets that one attribute. */
.workspace-shell[data-workspace-state="idle"] .preview-area,
.workspace-shell[data-workspace-state="loading"] .preview-area,
.workspace-shell[data-workspace-state="error"] .preview-area {
  display: none;
}

.workspace-shell[data-workspace-state="ready"] .upload-zone,
.workspace-shell[data-workspace-state="processing"] .upload-zone,
.workspace-shell[data-workspace-state="exporting"] .upload-zone {
  display: none;
}

.preview-area {
  text-align: center;
}

.preview-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  min-height: 200px;
  overflow: hidden;
}

.preview-slot canvas {
  max-width: 100%;
  max-height: 60vh;
  height: auto;
  width: auto;
  border-radius: var(--radius-sm);
}

.preview-meta {
  margin-top: var(--space-sm);
  font-size: var(--fs-xs);
  color: var(--color-text-secondary);
}

.workspace-status {
  font-size: var(--fs-xs);
  color: var(--color-text-secondary);
  margin-top: var(--space-sm);
  min-height: 1.2em;
}

.workspace-error {
  margin-top: var(--space-sm);
}

.workspace-error[hidden] {
  display: none;
}

.workspace-shell[data-workspace-state="loading"] .upload-zone,
.workspace-shell[data-workspace-state="exporting"] .tool-workspace__controls,
.workspace-shell[data-workspace-state="processing"] .tool-workspace__controls {
  opacity: 0.85;
}

/* ---- Image Cropper (Phase 03) ----
   The overlay is a real, absolutely-positioned DOM layer sitting exactly
   on top of the visible preview canvas — see cropper-renderer.js. */
.crop-overlay {
  position: absolute;
  pointer-events: none;
}

.crop-box {
  position: absolute;
  pointer-events: auto;
  cursor: move;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 9999px rgba(16, 32, 30, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
  touch-action: none;
}

.crop-box:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.crop-box.is-active {
  border-color: var(--color-accent);
}

.crop-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  opacity: 0;
  transition: opacity var(--motion-fast) var(--motion-ease);
  pointer-events: none;
}

.crop-box.is-active .crop-grid {
  opacity: 1;
}

.crop-grid__line {
  border-right: 1px solid rgba(255, 255, 255, 0.55);
  border-bottom: 1px solid rgba(255, 255, 255, 0.55);
}

.crop-grid__line:nth-child(3n) {
  border-right: none;
}

.crop-grid__line:nth-child(n+7) {
  border-bottom: none;
}

.crop-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border: 2px solid var(--color-primary);
  border-radius: 50%;
  box-sizing: border-box;
  touch-action: none;
  /* Visual handle is small; hit target is enlarged via padding-free
     absolute offset below (44px min touch target, P02/P03 a11y rule). */
}

.crop-handle::before {
  content: "";
  position: absolute;
  inset: -14px;
}

.crop-handle--nw { top: -8px; left: -8px; cursor: nwse-resize; }
.crop-handle--ne { top: -8px; right: -8px; cursor: nesw-resize; }
.crop-handle--sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.crop-handle--se { bottom: -8px; right: -8px; cursor: nwse-resize; }

/* ---- Ratio preset controls ----
   Selection is shown with a border + checkmark, never color alone. */
.ratio-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.ratio-btn {
  position: relative;
  padding-left: var(--space-lg);
}

.ratio-btn::before {
  content: "";
  position: absolute;
  left: var(--space-sm);
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  border: 2px solid var(--color-border-strong);
  border-radius: 50%;
  background: var(--color-surface);
}

.ratio-btn.is-active {
  border-color: var(--color-primary);
  font-weight: var(--fw-semibold);
}

.ratio-btn.is-active::before {
  border-color: var(--color-primary);
  background: var(--color-primary);
  box-shadow: inset 0 0 0 3px var(--color-surface);
}

.crop-dimensions {
  font-size: var(--fs-sm);
  color: var(--color-text-primary);
  margin: var(--space-sm) 0 0;
}

.tool-content h3 {
  font-size: var(--fs-md);
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: var(--fs-sm);
}

.feature-list li::before {
  content: "";
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--color-primary);
}

.related-tools__grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .related-tools__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---- Static page (About/Privacy/Terms/Contact) ---- */
.prose h2 {
  margin-top: var(--space-xl);
  font-size: var(--fs-lg);
}

.prose h2:first-child {
  margin-top: 0;
}

.prose ul,
.prose ol {
  color: var(--color-text-secondary);
}

.prose li {
  margin-bottom: var(--space-2xs);
}

.contact-form {
  max-width: 560px;
}

/* ---- 404 page ---- */
.error-page {
  text-align: center;
  padding-block: var(--space-3xl);
}

.error-page__code {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
  color: var(--color-primary);
  margin-bottom: 0;
}

.error-page__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

/* ---- Tools directory categories ---- */
.tools-category {
  margin-bottom: var(--space-2xl);
}

.tools-category:last-child {
  margin-bottom: 0;
}

.tools-category h2 {
  font-size: var(--fs-lg);
  margin-bottom: var(--space-md);
}
