/* ============ fonts ============ */
@font-face {
  font-family: 'Alexandria';
  src: url('assets/fonts/Alexandria-VF.ttf') format('truetype');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Thmanyah';
  src: url('assets/fonts/thmanyah-regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Thmanyah';
  src: url('assets/fonts/thmanyah-bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

/* ============ tokens ============ */
:root {
  --ink: #0B3D5C;
  --ink-soft: #155E75;
  --accent: #0284C7;
  --accent-deep: #0C4A6E;
  --sky-1: #EAF6FD;
  --sky-2: #D3ECF8;
  --sky-3: #B9E0F3;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-border: rgba(255, 255, 255, 0.9);
  --shadow: 0 20px 50px rgba(12, 74, 110, 0.14);
  --radius: 22px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  font-family: 'Alexandria', 'Thmanyah', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 80% -10%, #F4FBFF 0%, transparent 55%),
    radial-gradient(900px 700px at 10% 110%, #E3F4FC 0%, transparent 50%),
    linear-gradient(165deg, var(--sky-1) 0%, var(--sky-2) 48%, var(--sky-3) 100%);
  background-attachment: fixed;
}

body {
  position: relative;
  overflow-x: hidden;
  padding: 28px clamp(16px, 4vw, 48px) 40px;
}

/* ambient orbs */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
}
.orb-1 { width: 420px; height: 420px; top: -120px; left: -80px; background: radial-gradient(circle, #BFE8FA, transparent 70%); }
.orb-2 { width: 360px; height: 360px; bottom: -60px; right: -40px; background: radial-gradient(circle, #CFF0FF, transparent 70%); }
.orb-3 { width: 260px; height: 260px; top: 40%; left: 45%; background: radial-gradient(circle, #E8F7FF, transparent 70%); opacity: 0.3; }

/* ============ topbar ============ */
.topbar {
  position: relative;
  z-index: 2;
  max-width: 1280px;
  margin: 0 auto 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 22px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-hands { width: 52px; height: auto; }
.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-text strong {
  font-family: 'Alexandria';
  font-weight: 800;
  font-size: 18px;
  color: var(--accent-deep);
}
.brand-text span { font-size: 12.5px; color: var(--ink-soft); opacity: 0.85; }
.logos { display: flex; align-items: center; gap: 14px; }
.logos img { height: 56px; width: auto; object-fit: contain; }
.logos .eagle { height: 48px; }

/* ============ layout ============ */
.stage {
  position: relative;
  z-index: 2;
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 26px;
  align-items: start;
}
@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

/* ============ controls panel ============ */
.controls { padding: 26px 24px 28px; }
.controls h2 {
  font-family: 'Alexandria';
  font-weight: 800;
  font-size: 22px;
  margin-bottom: 8px;
  color: var(--accent-deep);
}
.hint {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink-soft);
  opacity: 0.9;
  margin-bottom: 20px;
}

.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 18px;
  border-radius: 16px;
  cursor: pointer;
  font-family: 'Alexandria';
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: 0 10px 26px rgba(2, 132, 199, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  user-select: none;
}
.upload-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(2, 132, 199, 0.42); }
.upload-btn:active { transform: translateY(0); }

.drop-zone {
  margin-top: 14px;
  border: 2px dashed rgba(2, 132, 199, 0.35);
  border-radius: 16px;
  padding: 22px 14px;
  text-align: center;
  font-size: 13.5px;
  color: var(--ink-soft);
  transition: border-color 0.2s, background 0.2s;
}
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(2, 132, 199, 0.08);
  color: var(--accent-deep);
  font-weight: 600;
}

.controls-body { margin-top: 22px; display: flex; flex-direction: column; gap: 18px; }
.controls-body[hidden] { display: none !important; }
.empty-note[hidden] { display: none !important; }
#photoImg[hidden] { display: none !important; }
.placeholder[hidden] { display: none !important; }
.drag-hint[hidden] { display: none !important; }

.control-row { display: flex; flex-direction: column; gap: 8px; }
.control-row > label {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-deep);
}
.zoom-line {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(12, 74, 110, 0.15);
  background: rgba(255, 255, 255, 0.85);
  color: var(--accent-deep);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: #fff; transform: scale(1.05); }

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--sky-3), var(--accent));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 3px 10px rgba(2, 132, 199, 0.4);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  cursor: pointer;
}
.zoom-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  min-width: 52px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ghost-btn {
  padding: 12px;
  border-radius: 14px;
  border: 1.5px solid rgba(12, 74, 110, 0.18);
  background: rgba(255, 255, 255, 0.65);
  color: var(--accent-deep);
  font-family: 'Alexandria';
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ghost-btn:hover { background: #fff; border-color: var(--accent); }

.primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-family: 'Alexandria';
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(135deg, #0EA5E9 0%, var(--accent-deep) 100%);
  box-shadow: 0 12px 30px rgba(12, 74, 110, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(12, 74, 110, 0.42); }
.primary-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.empty-note {
  margin-top: 22px;
  padding: 26px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
  border: 1.5px dashed rgba(12, 74, 110, 0.18);
  text-align: center;
  color: var(--ink-soft);
}
.note-icon { font-size: 34px; margin-bottom: 8px; opacity: 0.7; }
.empty-note p { font-size: 14px; font-weight: 600; }

/* ============ preview ============ */
.preview-panel {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.preview-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-deep);
  letter-spacing: 0.02em;
}
.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.9), transparent 45%),
    linear-gradient(160deg, #EAF6FD, #C9E8F7);
  user-select: none;
  touch-action: none;
  cursor: grab;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6);
}
.canvas-wrap.dragging { cursor: grabbing; }

/* circular hole clip — geometry matches frame.png (2835px, r=917, c≈50.3%/50.4%) */
.hole-clip {
  position: absolute;
  /* circle: center 50.3% / 50.4%, diameter = 2*917/2835 ≈ 64.7% */
  left: 50.3%;
  top: 50.4%;
  width: 64.66%;
  height: 64.66%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  overflow: hidden;
  z-index: 1;
  background: radial-gradient(circle at 50% 40%, #F0F9FF, #D7EEFA);
}
#photoImg {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center center;
  /* JS sets: translate(-50%,-50%) translate(px,px) rotate() scale() */
  will-change: transform;
  pointer-events: none;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}
.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: rgba(12, 74, 110, 0.4);
  font-size: 15px;
  font-weight: 600;
}
.placeholder svg { opacity: 0.55; }

.frame-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.drag-hint {
  position: absolute;
  bottom: 14%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 8px 18px;
  border-radius: 99px;
  background: rgba(11, 61, 92, 0.78);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(8px);
  pointer-events: none;
  animation: hintFade 3.2s ease forwards;
  white-space: nowrap;
}
@keyframes hintFade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

/* ============ footer ============ */
.foot {
  position: relative;
  z-index: 2;
  max-width: 1280px;
  margin: 28px auto 0;
  text-align: center;
  font-family: 'Alexandria';
  font-weight: 700;
  font-size: 15px;
  color: var(--accent-deep);
  opacity: 0.75;
}
