/* Aspect Ratio Calculator: styles for this tool only.
   The page shell (workspace, #stage, side panel and its mobile behaviour) comes from
   /tools/shared/css/pdf.css; shared components come from /tools/shared/tools.css. */

body {
  font-variant-numeric: tabular-nums;
}

/* ---------- stage ---------- */

.ar-scroll {
  flex: 1;
  padding: var(--space-4) var(--space-8) var(--space-12);
}
.ar-scroll > * {
  max-width: 44rem;
  margin-left: auto;
  margin-right: auto;
}

/* Preview: a rectangle drawn to the ratio, sized in px by aspect-ratio.js */
.ar-preview {
  display: grid;
  place-items: center;
  height: 20rem;
  padding: var(--space-4);
  border-radius: var(--radius-2xl);
  background: var(--color-surface);
}
.ar-rect {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-sizing: border-box;
  overflow: hidden;
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
  color: var(--color-ink);
  transition:
    width 0.25s cubic-bezier(0.3, 0.7, 0.2, 1),
    height 0.25s cubic-bezier(0.3, 0.7, 0.2, 1);
}
.ar-rect-ratio {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: 1.1;
  white-space: nowrap;
}
.ar-rect-size {
  font-size: var(--text-sm);
  color: var(--color-muted);
  white-space: nowrap;
}
.ar-rect.is-small .ar-rect-ratio {
  font-size: var(--text-sm);
}
.ar-rect.is-tiny .ar-rect-ratio,
.ar-rect.is-tiny .ar-rect-size,
.ar-rect.is-small .ar-rect-size {
  display: none;
}
.ar-rect.is-empty {
  border-style: dashed;
  border-color: var(--color-border);
  background: transparent;
}

/* Results */
.ar-results {
  margin-top: var(--space-4);
  margin-bottom: 0;
}
.ar-row {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) 0;
}
.ar-row + .ar-row {
  border-top: 1px solid var(--color-border);
}
.ar-row[hidden] {
  display: none;
}
.ar-row dt {
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.ar-value {
  min-width: 0;
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--color-ink);
  overflow-wrap: anywhere;
}
.ar-big {
  font-size: var(--text-xl);
  line-height: 1.2;
}
.ar-mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
}
.hint {
  margin-top: 0;
  margin-bottom: 0;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-muted);
}
.ar-note {
  min-height: 1.5em;
  margin-top: var(--space-2);
}

/* Common sizes: the shared .option button, one per resolution */
.ar-sizes {
  margin-top: var(--space-6);
}
.ar-sizes .sub-head {
  margin: 0 0 var(--space-3);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: 1.25rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.ar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.ar-grid .option {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.ar-grid .option-title {
  font-size: var(--text-md);
}
.ar-empty {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--color-muted);
}

/* ---------- settings panel ---------- */

@media (min-width: 861px) {
  body.panel-open .panel {
    width: clamp(20rem, 32%, 28rem);
  }
}
.panel-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-3);
  align-content: start;
  align-items: start;
  padding-top: var(--space-2);
  padding-bottom: var(--space-4);
}
.panel-body > * {
  min-width: 0;
}
.panel-body .f {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}
.panel-body .f.full,
.panel-body .note {
  grid-column: 1 / -1;
}
.panel-body .field-label {
  padding: 0 0 var(--space-1);
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  line-height: 1.25rem;
  color: var(--color-muted);
}
.panel-body .field,
.panel-body .dropdown-btn,
.panel-body .segmented {
  height: 2.75rem;
  box-sizing: border-box;
}
.panel-body .segmented {
  align-items: stretch;
}
.panel-body .segmented button {
  padding: 0 var(--space-2);
}
.panel-body .dropdown-btn .dropdown-name {
  min-width: 0;
}
.panel-body .dropdown-btn .dropdown-meta,
.panel-body .dropdown-btn .icon {
  flex: none;
}
.panel-body [hidden] {
  display: none;
}
.note {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-warning);
}

/* ---------- small screens ---------- */

@media (max-width: 860px) {
  .ar-scroll {
    padding: var(--space-3) var(--space-4) var(--space-8);
  }
  .ar-preview {
    height: 14rem;
  }
}
@media (max-width: 560px) {
  .ar-row {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 2px;
    padding: var(--space-3) 0;
  }
  .ar-row dt {
    grid-column: 1;
  }
  .ar-row .ar-value {
    grid-column: 1;
    grid-row: 2;
  }
  .ar-row .btn {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
  .ar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (prefers-reduced-motion: reduce) {
  .ar-rect {
    transition: none;
  }
}
