/* Marker face used for artwork text drawn onto the canvas (e.g. Template 2's editable year).
   Chosen to match the hand-lettered "1995 VERSION" already baked into template2/template.png. */
@font-face {
  font-family: 'BaksoSapi';
  src: url('assets/fonts/BaksoSapi.otf') format('opentype');
  font-display: block;
}

@font-face {
  font-family: 'SymphonyPro';
  src: url('assets/fonts/SymphonyPro.otf') format('opentype');
  font-display: block;
}

:root {
  --navy: #1b2860;        /* headings / primary ink, matches the picker cards */
  --pink-accent: #1b2860; /* single interactive accent, now navy like the picker */
  --danger: #d05a5a;      /* required-field marker + errors */
  --card-bg: #ffffff;
  --muted: #aa9ba7;
  --line: #e9e9e9;        /* neutral hairlines on inputs/chips/toggles */
  --field: #fcfcfc;       /* neutral input fill */
  --logo-color: #1b2860;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  background: #ffffff;
  color: #000;
  min-height: 100vh;
}

.page {
  /* Column layout so .footer can be pinned to the bottom on short pages. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 680px;
  margin: 0 auto;
  padding: 28px 24px 22px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  font-weight: 600;
  font-size: 12px;
  color: #6b6b6b;
  text-decoration: none;
  margin-bottom: 18px;
}
.back-link:hover { text-decoration: underline; }

.hero {
  text-align: center;
  margin-bottom: 34px;
}

.hero-logo {
  width: 46px;
  height: auto;
  display: block;
  margin: 0 auto 26px;
}

.hero h1 {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .02em;
  color: #000;
  margin: 0 0 6px;
}

.subtitle {
  font-size: 15px;
  color: #000;
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.45;
}

.card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .10), 0 6px 16px rgba(0, 0, 0, .05);
}

.card h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 16px;
}

.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--pink-accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.section-header-row h2 { margin: 0; }

.reset-btn {
  background: none;
  border: none;
  color: var(--navy);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  flex-shrink: 0;
}
.reset-btn:hover { background: #f2f4f8; }

/* Order form */
.form-field { margin-bottom: 18px; }
.form-field:last-child { margin-bottom: 0; }
.form-field label {
  display: block;
  font-weight: 700;
  font-size: 13px;
  color: var(--navy);
  margin-bottom: 8px;
}

.required-mark {
  color: var(--danger);
}

.text-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: #000;
  font-family: var(--sans);
  font-size: 14px;
  outline: none;
}
.text-input:focus { border-color: var(--navy); background: #fff; }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--field);
  color: #000;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.chip:hover { border-color: var(--pink-accent); }
.chip.selected {
  background: var(--pink-accent);
  border-color: var(--pink-accent);
  color: #fff;
}

/* Upload grid */
.section-hint {
  margin: -8px 0 14px;
  font-size: 12px;
  color: #a89aa3;
}

.upload-grid {
  display: grid;
  gap: 10px;
}

.upload-grid-loading {
  grid-column: 1 / -1;
  text-align: center;
  color: #a89aa3;
  font-size: 13px;
  padding: 30px 0;
  margin: 0;
}

.upload-slot {
  position: relative;
  border: 2px dashed #dcdcdc;
  border-radius: 10px;
  background: var(--field);
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: var(--slot-ratio, 3/4);
  transition: border-color .15s ease, background .15s ease;
}

.upload-slot:hover, .upload-slot.dragover {
  border-color: var(--navy);
  background: #f5f7fb;
}

.upload-slot.filled {
  border-style: solid;
  border-color: #eee;
}

.upload-slot-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #b4b4b4;
}

.upload-slot-empty .plus {
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
}

.upload-slot-num {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  color: var(--navy);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.upload-slot-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.upload-slot.filled { cursor: grab; }
.upload-slot.filled:active { cursor: grabbing; }
.upload-slot.drag-source { opacity: 0.35; }

.upload-slot-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-slot-edit-hint {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}

/* Position/zoom editor modal */
.editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 25, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.editor-modal {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
  max-height: 92vh;
  overflow-y: auto;   /* short/landscape phones can still reach the buttons */
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.editor-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--navy);
  margin: 0 0 14px;
  text-align: center;
}

.editor-viewport {
  border-radius: 14px;
  overflow: hidden;
  background: #f2ecec;
  margin: 0 auto;
  max-width: 280px;
  touch-action: none;
}

.editor-viewport canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: grab;
}

.editor-viewport canvas:active { cursor: grabbing; }

.editor-hint {
  text-align: center;
  color: #a89aa3;
  font-size: 12px;
  margin: 8px 0 0;
}

.editor-zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 4px;
}

.editor-zoom-icon {
  color: var(--pink-accent);
  font-weight: 700;
  width: 14px;
  text-align: center;
}

.editor-zoom-row input[type="range"] {
  flex: 1;
  accent-color: var(--pink-accent);
}

.editor-actions {
  /* Grid, not flex-wrap: with `flex:1` a button left alone on the last row stretched
     to the full modal width, which looked broken on phones. 2x2 stays even at any size. */
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.editor-btn {
  padding: 11px 10px;
  border-radius: 8px;
  border: none;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.editor-btn-ghost {
  background: #f2f3f5;
  color: var(--navy);
}
.editor-btn-ghost:hover { background: #e8eaee; }

.editor-btn-primary {
  background: var(--navy);
  color: #fff;
}

/* Logo preview */
.logo-preview {
  background: #faf3ea;
  border: 1px solid #ece1d3;
  border-radius: 10px;
  padding: 30px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.logo-preview canvas { width: 100%; max-width: 340px; height: auto; display: block; }

/* Swatches */
.swatches {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--sw, #ccc);
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
}

.swatch.selected {
  box-shadow: 0 0 0 2.5px var(--sw, var(--navy));
}

.swatch .check {
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: none;
}

.swatch.selected .check { display: block; }

.swatch-rainbow {
  background: conic-gradient(red, orange, yellow, green, blue, violet, red);
  overflow: hidden;
}

.swatch-rainbow input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}

.hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.color-group-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--navy);
  margin: 0 0 10px;
}

/* Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.toggle-title {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 14px;
  color: var(--navy);
}

.toggle-desc {
  margin: 0;
  font-size: 12px;
  color: #a89aa3;
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch-slider {
  position: absolute;
  inset: 0;
  background: #dcdcdc;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.switch input:checked + .switch-slider {
  background: var(--pink-accent);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

/* Generate button */
.generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(27, 40, 96, 0.22);
  transition: transform .1s ease, box-shadow .1s ease;
}

.generate-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 20px rgba(27, 40, 96, 0.30);
}

.generate-btn:active { transform: translateY(0); }

.generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin: 12px 0 0;
  text-align: center;
}

/* Result */
.result-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.result-preview img {
  max-width: 100%;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}

.download-btn { background: #2f9e52; box-shadow: 0 4px 14px rgba(47, 158, 82, 0.28); }
.download-btn:hover { box-shadow: 0 7px 20px rgba(47, 158, 82, 0.36); }

.footer {
  margin-top: auto;      /* pins the credit to the bottom, same as the picker */
  padding-top: 48px;
  font-size: 11px;
  color: #000;
}

#workCanvas { display: none; }

/* --- Template pages: small screens --- */
@media (max-width: 600px) {
  .page { padding: 22px 16px 20px; }
  .card { padding: 18px 16px; }
  .hero { margin-bottom: 26px; }
  .hero-logo { width: 40px; margin-bottom: 20px; }
  .subtitle { font-size: 14px; }
  .upload-grid { gap: 8px; }
  .swatches { gap: 10px; }
}

@media (max-width: 380px) {
  .page { padding: 20px 12px 18px; }
  .card { padding: 15px 12px; }
  /* The switch alone eats ~62px of a ~250px row, leaving the label too narrow to
     read — stacking gives the copy the full width instead. */
  .toggle-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .upload-grid { gap: 6px; }
  .chip { padding: 8px 13px; font-size: 12.5px; }
}

/* Template gallery (landing page) */

/* ==========================================================================
   Template picker (index.html only — scoped to body.picker so the per-template
   pages keep their own pink/rounded styling untouched).
   Flat white layout: centred crest + heading, a 5-up card grid, and the credit
   line pinned bottom-left.
   ========================================================================== */

body.picker {
  background: #ffffff;
  color: #000;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

.picker-page {
  /* Column layout + min-height is what lets .picker-footer sit at the bottom of
     the viewport on short pages while still being pushed down by a long grid. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1220px;
  margin: 0 auto;
  padding: 44px 24px 22px;
}

.picker-head {
  text-align: center;
  margin-bottom: 42px;
}

.picker-logo {
  width: 52px;
  height: auto;
  display: block;
  margin: 0 auto 34px;
}

.picker-head h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .02em;
  margin: 0 0 6px;
  color: #000;
}

.picker-head p {
  font-size: 15px;
  line-height: 1.45;
  margin: 0 auto;
  max-width: 760px;
  color: #000;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 32px;
}

.picker-card {
  background: #fff;
  border-radius: 10px;
  padding: 12px 12px 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .10), 0 6px 16px rgba(0, 0, 0, .05);
  transition: transform .15s ease, box-shadow .15s ease;
}

.picker-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 12px 28px rgba(0, 0, 0, .10);
}

.picker-card-thumb {
  background: #faf3ea;
  border-radius: 8px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 14px;
}

.picker-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
}

.picker-card-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #1b2860;
  margin: 0 0 5px;
  line-height: 1.3;
}

.picker-card-desc {
  font-size: 11px;
  line-height: 1.55;
  color: #aa9ba7;
  margin: 0;
}

.picker-footer {
  margin-top: auto;      /* pins the credit to the bottom of the page */
  padding-top: 60px;
  font-size: 11px;
  color: #000;
}

@media (max-width: 1100px) {
  .picker-grid { grid-template-columns: repeat(4, 1fr); gap: 26px; }
}
@media (max-width: 880px) {
  .picker-grid { grid-template-columns: repeat(3, 1fr); gap: 22px; }
}
@media (max-width: 640px) {
  .picker-page { padding: 34px 18px 20px; }
  .picker-grid { grid-template-columns: repeat(2, 1fr); gap: 18px; }
  .picker-head { margin-bottom: 30px; }
}
@media (max-width: 400px) {
  .picker-grid { grid-template-columns: 1fr; }
}
