/* ============================================================
   IDENTIO ATLAS — Poster Editor
   Blurred Glass Poster Customizer
   ============================================================ */

/* ── Font ─────────────────────────────────────────────────── */
@font-face {
  font-family: 'Whoami';
  src: url('font/Whoami-Regular.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'InstrumentSerif';
  src: url('font/InstrumentSerif-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'InstrumentSerif';
  src: url('font/InstrumentSerif-Italic.ttf') format('truetype');
  font-weight: normal;
  font-style: italic;
  font-display: swap;
}

/* ── Design Tokens ───────────────────────────────────────── */
:root {
  /* Editor */
  --editor-bg: #0b0b0b;
  --editor-border: rgba(255, 255, 255, 0.06);
  --editor-text: #d4d4d4;
  --editor-text-muted: #6b6b6b;
  --accent: #b39cdb;
  /* Canvas / Poster */
  --c-height: min(84vh, 792px);

  /* Transition */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background: var(--editor-bg);
  color: var(--editor-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Editor Layout ────────────────────────────────────────── */
.editor {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

.editor-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  padding: 24px;
  gap: 24px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(198, 156, 109, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(198, 156, 109, 0.03) 0%, transparent 60%),
    var(--editor-bg);
}

/* ── Canvas Area ──────────────────────────────────────────── */
.canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* ── A3 Canvas ────────────────────────────────────────────── */
.canvas {
  /* Default dark theme tokens */
  --poster-text: #eee5e0;
  --poster-text-year: rgba(238, 229, 224, 0.85);
  --poster-text-active: rgba(238, 229, 224, 0.4);
  --poster-info-color: rgba(238, 229, 224, 0.45);
  --poster-border: none;

  position: relative;
  height: var(--c-height);
  aspect-ratio: 297 / 420;
  background: #17171b;
  border-radius: 2px;
  overflow: hidden;
  border: var(--poster-border);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.4),
    0 24px 80px rgba(0, 0, 0, 0.5);
  transition: background-color 0.4s ease, border 0.4s ease, box-shadow 0.4s ease;
}

.canvas.light-bg {
  /* Light theme tokens for high readability */
  --poster-text: #0b0b0b;
  --poster-text-year: rgba(11, 11, 11, 0.85);
  --poster-text-active: rgba(11, 11, 11, 0.4);
  --poster-info-color: rgba(11, 11, 11, 0.45);
  --poster-border: 1px solid #0b0b0b;
}

/* ── Layers ────────────────────────────────────────────────── */
.layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}



/* Blocks Layer (behind glass) */
.layer-blocks {
  z-index: 2;
  will-change: contents;
}

/* Projects Layer (topmost) */
.layer-projects {
  z-index: 4;
  pointer-events: none; /* Let clicks/drags pass through to the canvas */
  padding: calc(var(--c-height) * 0.03) calc(var(--c-height) * 0.05 * 0.707) calc(var(--c-height) * 0.03);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* ── Projects Marquee Container ────────────────────────────── */
.projects-marquee-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding-top: calc(var(--c-height) * 0.03);
  padding-bottom: calc(var(--c-height) * 0.03);
}

.projects-scroll-wrapper {
  display: flex;
  flex-direction: column;
  animation: vertical-marquee 90s linear infinite;
}

.projects-list-block {
  display: flex;
  flex-direction: column;
}

.project-name {
  font-family: 'InstrumentSerif', Georgia, serif;
  font-size: calc(var(--c-height) * 0.052);
  font-weight: 400;
  letter-spacing: -0.03em;
  color: var(--poster-text);
  pointer-events: auto; /* Enable clicking only on the project names */
  cursor: pointer;
  padding: calc(var(--c-height) * 0.003) 0;
  white-space: nowrap;
  line-height: 0.95;
  position: relative;
  user-select: none;
  display: block;
  text-transform: uppercase;
  transition: opacity 0.2s ease;
}

/* Year superscript */
.project-year {
  font-family: 'InstrumentSerif', Georgia, serif;
  font-size: 0.42em;
  font-weight: 400;
  vertical-align: baseline;
  margin-left: 6px;
  position: relative;
  top: -0.1em;
  opacity: 0.8;
  color: var(--poster-text-year);
}

.project-name:hover {
  opacity: 0.6;
}

.project-name.is-active {
  color: var(--poster-text-active);
}

@keyframes vertical-marquee {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-50%);
  }
}

/* ── Poster Info (Top Right Vertical Stack) ────────────────── */
.poster-info {
  position: absolute;
  top: calc(var(--c-height) * 0.035);
  right: calc(var(--c-height) * 0.05 * 0.707);
  font-family: 'InstrumentSerif', Georgia, serif;
  font-style: italic;
  font-size: calc(var(--c-height) * 0.0173); /* 1/3 of project name font-size (0.052) */
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--poster-info-color);
  text-align: right;
  line-height: 1.0;
  z-index: 5;
  pointer-events: none;
}

/* ── Physics Simulation Canvas ────────────────────────────── */
#blocks-layer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: relative;
  flex-shrink: 0;
  width: 250px;
  height: 100%;
  background: rgba(22, 22, 22, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  z-index: 100;
  box-shadow: 
    0 10px 30px rgba(0, 0, 0, 0.3),
    0 1px 0 rgba(255, 255, 255, 0.05) inset;
  overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}


.sidebar-section h3 {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--editor-text-muted);
  margin-bottom: 14px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.export-buttons-group {
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.btn-export {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 12px 10px;
  background: linear-gradient(135deg, #d3c4ec 0%, #b39cdb 100%);
  color: #171520;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;

  cursor: pointer;
  transition: all 0.3s var(--ease-out-expo);
  position: relative;
  overflow: hidden;
  font-weight: 600;
}

.btn-export::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.2) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn-export:hover {
  transform: translateY(-2px);
  box-shadow:
    0 6px 20px rgba(179, 156, 219, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-export:hover::before {
  opacity: 1;
}

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

.btn-export .btn-icon {
  font-size: 24px;
  line-height: 1;
}

.btn-export .btn-sub {
  font-size: 9px;
  opacity: 0.8;
}

.btn-secondary {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--editor-text);
  border: 1px solid var(--editor-border);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.btn-secondary:active {
  transform: scale(0.98);
}


/* ── Block Count Badge ────────────────────────────────────── */
.block-count {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.04em;
}

.block-count-number {
  font-size: 18px;
  color: var(--accent);
  letter-spacing: -0.02em;
}

/* ── Sidebar Info ─────────────────────────────────────────── */
.sidebar-info {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-info p {
  font-size: 9px;
  color: var(--editor-text-muted);
  line-height: 1.6;
  letter-spacing: 0.03em;
  text-align: left;
}

/* ── Export Loading Overlay ───────────────────────────────── */
.export-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.export-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.export-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(198, 156, 109, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.export-overlay p {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--accent);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    width: 220px;
    padding: 16px 12px;
  }
}

@media (max-width: 700px) {
  .editor-body {
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }

  .canvas-area {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 8px;
  }

  .canvas {
    width: calc((100vh - 200px) * 297 / 420);
    max-width: 95%;
    height: auto;
    aspect-ratio: 297 / 420;
  }

  .sidebar {
    width: 100%;
    height: auto;
    min-width: unset;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    padding: 16px;
    gap: 16px;
    overflow: hidden;
  }

  .sidebar-section {
    flex-shrink: unset;
    min-width: unset;
    margin-bottom: 0;
  }

  /* Define layout order */
  .sidebar-section:nth-child(1) { /* Export */
    order: 4;
  }
  .sidebar-section:nth-child(2) { /* Background */
    order: 3;
  }
  .sidebar-section:nth-child(3) { /* Blocks */
    order: 1;
  }
  .sidebar-section:nth-child(4) { /* Clear All Blocks */
    order: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }

  /* Unify heights for Blocks count and Clear All Blocks button */
  .block-count, .btn-secondary {
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 16px;
  }
  .block-count {
    justify-content: space-between;
  }
  .btn-secondary {
    justify-content: center;
  }

  .sidebar-info {
    display: none;
  }

  .bg-options {
    gap: 6px;
    padding: 6px 8px;
    margin-top: 10px;
  }

  .bg-swatch, .bg-picker-container {
    width: 20px;
    height: 20px;
  }

  .custom-color-popover {
    width: 220px;
    left: 0;
    right: auto;
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 10px;
  }
}

/* ── Print / PDF Export Mode ──────────────────────────────── */
.canvas.is-exporting .project-name {
  cursor: default;
}

.canvas.is-exporting .project-name::after {
  display: none;
}

/* ── Background Color Options ── */
.bg-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  background: rgba(0, 0, 0, 0.65); /* Black translucent background */
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  padding: 8px 12px;
  border: none; /* No border */
}

.bg-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none; /* No border */
  cursor: pointer;
  outline: none;
  transition: transform 0.2s ease;
  position: relative;
  padding: 0;
}

.bg-swatch:hover {
  transform: scale(1.2);
}

/* Active indicator: white dot in the center of the active swatch */
.bg-swatch.active::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  background-color: #ffffff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Dark dot indicator for light swatches to remain visible */
.bg-swatch[data-color="#eee5e0"].active::after {
  background-color: #17171b;
}

.bg-picker-container {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none; /* No border */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: conic-gradient(from 0deg, red, yellow, lime, aqua, blue, magenta, red); /* Spectrum gradient shape instead of emoji */
  transition: transform 0.2s ease;
  overflow: hidden;
}

.bg-picker-container:hover {
  transform: scale(1.2);
}

.bg-picker-container.active::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  background-color: #ffffff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ── Custom Color Picker Popover ── */
.custom-color-popover {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 10px;
  background: rgba(11, 11, 11, 0.96); /* Pure deep black transparent background */
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 12px;
  padding: 14px;
  border: none; /* Borderless */
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: none; /* Toggled in JS */
}

.custom-color-popover.is-open {
  display: block;
  animation: fadeInPopover 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInPopover {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.popover-header {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.color-square-wrapper {
  position: relative;
  width: 100%;
  height: 110px;
  border-radius: 8px;
  overflow: hidden;
  cursor: crosshair;
  margin-bottom: 12px;
}

#color-square {
  width: 100%;
  height: 100%;
  display: block;
  background-color: transparent;
}

.color-cursor {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, -50%);
  pointer-events: none;
  top: 0;
  left: 0;
}

.popover-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.color-preview-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #17171b;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  transition: background-color 0.15s ease;
}

.hue-slider-wrapper {
  flex-grow: 1;
  display: flex;
  align-items: center;
}

#hue-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, red, yellow, lime, aqua, blue, magenta, red);
  outline: none;
  cursor: pointer;
  margin: 0;
}

#hue-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid #111111;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  cursor: pointer;
}

.popover-inputs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.input-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.input-col input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: 6px;
  padding: 6px 4px;
  color: #ffffff;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: background-color 0.15s, box-shadow 0.15s;
}

.input-col input:focus {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 1px rgba(179, 156, 219, 0.5);
}

.input-col label {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 4px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.popover-footer {
  display: flex;
}

.popover-btn {
  width: 100%;
  background: #ffffff; /* Minimal white button */
  color: #0b0b0b;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
  transition: background-color 0.2s, transform 0.1s;
}

.popover-btn:hover {
  background: #e5e5e5;
}

.popover-btn:active {
  transform: scale(0.97);
}
