/* ── Reset & base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --black:   #0a0a0a;
  --white:   #ffffff;
  --grey-50: #f7f7f7;
  --grey-100:#efefef;
  --grey-300:#cccccc;
  --grey-500:#888888;
  --grey-700:#444444;
  --accent:  #0a0a0a;
  --danger:  #c0392b;
  --radius:  10px;
  --shadow:  0 2px 16px rgba(0,0,0,.08);
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background-image: url('/static/bg-pattern.png');
  background-size: 480px auto;
  background-repeat: repeat;
  color: var(--black);
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────────────────── */
.page-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ── Header ─────────────────────────────────────────────────────── */
.site-header {
  padding: 36px 0 28px;
  text-align: center;
}
.header-logo {
  height: 36px;
  margin-bottom: 16px;
  display: block;
  margin-inline: auto;
}
.site-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.site-header h1 span {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--black);
  margin-top: 4px;
}
.header-sub {
  margin-top: 8px;
  color: var(--black);
  font-size: .9rem;
  font-weight: 500;
}

/* admin header */
.admin-header { display: flex; align-items: center; justify-content: space-between; text-align: left; gap: 16px; flex-wrap: wrap; }
.admin-header-right { display: flex; align-items: center; gap: 16px; }
.admin-header-right h1 { font-size: 1.25rem; }

/* ── Card ───────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--grey-100);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.step-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--grey-500);
  margin-bottom: 20px;
}

/* ── Upload zone ────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--grey-300);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: pointer;
}
.upload-zone.drag-over {
  border-color: var(--black);
  background: var(--grey-50);
}
.upload-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  color: var(--grey-500);
}
.upload-hint { color: var(--grey-700); margin-bottom: 16px; }
.upload-spec  { font-size: .8rem; color: var(--grey-500); margin-top: 14px; }

/* ── Rules box ──────────────────────────────────────────────────── */
.rules-box {
  margin-top: 20px;
  background: #fffbe6;
  border: 1.5px solid #f0d800;
  border-radius: 8px;
  padding: 16px 20px;
}
.rules-title {
  font-size: .8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--black);
  margin-bottom: 10px;
}
.rules-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rules-list li {
  font-size: .875rem;
  color: var(--black);
  line-height: 1.45;
}

.upload-error {
  margin-top: 16px;
  background: #fdf0ee;
  border: 1px solid #f5c6c0;
  color: var(--danger);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: .875rem;
}
.upload-success {
  margin-top: 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  border-radius: 6px;
  padding: 12px 16px;
  font-size: .875rem;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-primary  { background: var(--black); color: var(--white); }
.btn-primary:hover  { background: #333; }
.btn-outline  { background: transparent; color: var(--black); border-color: var(--black); }
.btn-outline:hover  { background: var(--grey-50); }
.btn-danger   { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover   { background: #fdf0ee; }
.btn-sm  { padding: 6px 14px; font-size: .8rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Cover spread ───────────────────────────────────────────────── */
/*
  Full-spread layout: the user's image fills the ENTIRE background
  (back cover + spine + front cover).
  Logos and fold lines are overlaid on top via absolute positioning.

  Proportions (% of spread width) derived from original template:
    Back  cover : 0  – 43%
    Spine       : 43 – 55%   (center ≈ 49%)
    Front cover : 55 – 100%
    Left  dashed fold : 40%
    Left  solid  fold : 43%
    Right solid  fold : 55%
    Right dashed fold : 58%
*/

.cover-wrapper {
  overflow-x: auto;
  padding: 8px 0 12px;
}

/* The spread itself — aspect ratio matches the template PNG (3025×1834) */
.cover-spread {
  position: relative;
  width: 100%;
  max-width: 860px;
  aspect-ratio: 3025 / 1834;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 3px;
  box-shadow: 0 4px 24px rgba(0,0,0,.14);
}

/* Canvas: full-bleed background (drawn by JS) */
.cover-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Admin gallery: <img> used instead of canvas */
.cover-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Template PNG overlay: white→transparent via multiply, black logos stay */
.cover-template-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  mix-blend-mode: multiply;
}

/* ── Preview actions ────────────────────────────────────────────── */
.preview-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ── Done card ──────────────────────────────────────────────────── */
.done-card {
  text-align: center;
  padding: 56px 32px;
}
.done-icon {
  font-size: 3rem;
  color: #166534;
  margin-bottom: 16px;
}
.done-card h2 { font-size: 1.5rem; margin-bottom: 10px; }
.done-card p  { color: var(--grey-700); margin-bottom: 28px; line-height: 1.6; }

/* ── Login ──────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrap {
  background: var(--white);
  border: 1px solid var(--grey-100);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo  { height: 32px; margin: 0 auto 20px; display: block; }
.login-wrap h2 { font-size: 1.25rem; margin-bottom: 6px; }
.login-sub { color: var(--grey-500); font-size: .875rem; margin-bottom: 24px; }
.login-error {
  background: #fdf0ee;
  border: 1px solid #f5c6c0;
  color: var(--danger);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: .875rem;
  margin-bottom: 16px;
}
.login-form { text-align: left; }
.login-form label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 6px; color: var(--grey-700); text-transform: uppercase; letter-spacing: .05em; }
.login-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--grey-300);
  border-radius: 6px;
  font-size: .95rem;
  margin-bottom: 16px;
  outline: none;
  transition: border-color .2s;
}
.login-form input:focus { border-color: var(--black); }

/* ── Admin gallery ──────────────────────────────────────────────── */
.gallery-count {
  font-size: .875rem;
  color: var(--grey-500);
  margin-bottom: 20px;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.gallery-card {
  background: var(--white);
  border: 1px solid var(--grey-100);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.gallery-card-meta {
  padding: 12px 14px 4px;
}
.gallery-card-name {
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-card-date {
  font-size: .75rem;
  color: var(--grey-500);
  margin-top: 3px;
}
.gallery-card-actions {
  padding: 10px 14px 14px;
  display: flex;
  gap: 8px;
  margin-top: auto;
}

/* ── Empty state ────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 72px 24px;
  color: var(--grey-700);
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { margin-bottom: 24px; font-size: 1rem; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .card { padding: 20px 16px; }
  .site-header { padding: 24px 0 20px; }
  .preview-actions { justify-content: stretch; }
  .preview-actions .btn { flex: 1; }
  .admin-header { flex-direction: column; align-items: flex-start; }
}
