/* Photo Frame PDF — uses the shared color tokens from assets/style.css */

body.wide {
  max-width: 1080px;
}

.back-link {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.spec-line {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--fg);
  opacity: 0.7;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0;
  margin: 0 0 1rem;
}

.lede {
  opacity: 0.8;
  max-width: 50ch;
}

/* --- Layout: fluid, not fixed-column-until-a-breakpoint --- */

.tool-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 2.5rem);
  align-items: start;
}

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

.controls {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

.field-group h2 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.field-row label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  flex: 1;
  min-width: 90px;
}

.field-row label:has(input[type="radio"]) {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}

.orientation-row {
  display: flex;
  gap: 0.4rem;
}

.orientation-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.75;
}

.orientation-option:hover {
  border-color: var(--accent);
  color: var(--accent);
  opacity: 1;
}

.orientation-option:has(input:checked) {
  border-color: var(--accent);
  color: var(--accent);
  opacity: 1;
}

.orientation-option input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.orientation-option:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.orientation-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
}

input[type="number"] {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--fg);
  font-size: 0.95rem;
  width: 100%;
}

input[type="number"]:focus-visible,
input[type="radio"]:focus-visible,
.presets button:focus-visible,
button.primary:focus-visible,
button.secondary:focus-visible,
.remove-photo-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.presets button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.presets button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.bleed-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
}

button.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  width: 100%;
}

button.secondary:hover {
  border-color: var(--accent);
}

.status-msg {
  font-size: 0.82rem;
  min-height: 1.2em;
  opacity: 0.8;
}

/* --- Photo list --- */

.photo-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.photo-item {
  position: relative;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  padding-right: 2rem;
}

.photo-item-crop .crop-stage {
  position: relative;
  width: 96px;
  height: 96px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: repeating-conic-gradient(#8884 0% 25%, transparent 0% 50%) 50% / 16px 16px;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.photo-item-crop .crop-stage.dragging {
  cursor: grabbing;
}

.photo-item-crop canvas {
  display: block;
}

.photo-item-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.remove-photo-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 1.5rem;
  height: 1.5rem;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  opacity: 0.6;
  cursor: pointer;
  font-size: 1rem;
}

.remove-photo-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  opacity: 1;
}

/* --- Page layout preview --- */

.preview-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  min-width: 0;
  width: 100%;
}

.pages-preview {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  width: 100%;
  position: relative;
  min-height: 200px;
}

.page-sheet {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: color-mix(in srgb, var(--fg) 3%, transparent);
  overflow: hidden;
}

.page-sheet .page-label {
  position: absolute;
  bottom: 0.35rem;
  right: 0.5rem;
  font-size: 0.7rem;
  opacity: 0.5;
  pointer-events: none;
}

.packed-item {
  position: absolute;
  border: 1px solid var(--border);
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.placeholder {
  margin: 0;
  opacity: 0.6;
  font-size: 0.9rem;
  align-self: center;
}

@media (prefers-reduced-motion: no-preference) {
  .presets button,
  button.secondary,
  button.primary,
  .remove-photo-btn,
  .photo-item-crop .crop-stage {
    transition: border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  }
}
