/* ========================================
   Indrammerske — Minimalist Frame Calculator
   ======================================== */

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

:root {
  --bg: #FAFAFA;
  --fg: #0A0A0A;
  --muted: #F5F5F5;
  --muted-fg: #999;
  --border: #E8E8E8;
  --border-hover: #D0D0D0;
  --accent: #171717;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- Header ---- */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 48px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.admin-link {
  font-size: 0.8125rem;
  color: var(--muted-fg);
  text-decoration: none;
  transition: color var(--transition);
}

.admin-link:hover {
  color: var(--fg);
}

/* ---- Calculator Layout ---- */

.calculator {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: calc(100vh - 73px);
  max-width: 1400px;
  margin: 0 auto;
}

/* ---- Preview Panel ---- */

.preview-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.preview-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#framePreview {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* SVG Elements */

/* SVG geometry transitions (x, y, width, height are CSS properties in SVG2) */
.svg-frame-inner,
.svg-glass,
.svg-passepartout,
.svg-pp-core,
.svg-artwork {
  transition: x 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
              y 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
              width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
              height 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
              fill 0.4s ease,
              opacity 0.3s ease;
}

/* Suppress all SVG transitions during initial render */
.no-transitions * {
  transition: none !important;
}

.svg-frame-piece {
  transition: fill 0.4s ease;
  stroke: none;
}

.svg-miter {
  stroke: rgba(0, 0, 0, 0.04);
  stroke-width: 0.08;
  stroke-linecap: round;
}

.svg-frame-inner {
  fill: none;
  stroke: rgba(0, 0, 0, 0.08);
  stroke-width: 0.3;
}

.svg-glass {
  fill: rgba(200, 220, 240, 0.08);
}

.svg-pp-core {
  fill: none;
  stroke-width: 0.4;
  stroke: #FFFFFF;
}

.svg-artwork {
  fill: #F0EDE8;
}

.svg-art-line {
  stroke: #E0DBD4;
  stroke-width: 0.15;
  transition: opacity 0.3s ease;
}

.dimension {
  opacity: 0.4;
}

.dim-line {
  stroke: var(--fg);
  stroke-width: 0.12;
}

.dim-cap {
  stroke: var(--fg);
  stroke-width: 0.12;
}

.dim-text {
  font-family: 'Inter', sans-serif;
  font-size: 2.2px;
  fill: var(--fg);
  font-weight: 300;
  letter-spacing: 0.05px;
}

/* ---- Image Drop Zone ---- */

.image-drop {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
}

.image-drop:hover {
  border-color: var(--border-hover);
  background: var(--muted);
}

.image-drop.dragover {
  border-color: var(--accent);
  background: var(--muted);
  border-style: solid;
}

.image-drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted-fg);
  font-size: 0.8125rem;
}

.image-drop-icon {
  width: 28px;
  height: 28px;
  color: var(--border-hover);
}

.image-drop-browse {
  background: none;
  border: none;
  color: var(--fg);
  font-family: inherit;
  font-size: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
}

.image-drop-browse:hover {
  color: var(--accent);
}

.image-drop-preview {
  display: flex;
  align-items: center;
  gap: 12px;
}

.image-drop-preview img {
  height: 48px;
  width: auto;
  max-width: 120px;
  border-radius: 4px;
  object-fit: cover;
}

.image-drop-remove {
  background: none;
  border: none;
  color: var(--muted-fg);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color var(--transition);
  line-height: 1;
}

.image-drop-remove:hover {
  color: #D32F2F;
}

/* ---- Controls Panel ---- */

.controls-panel {
  padding: 48px 48px 48px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

/* ---- Steps ---- */

.step {
  padding: 28px 32px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: all var(--transition);
}

.step:hover {
  border-color: var(--border);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.step-number {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--fg);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 500;
  flex-shrink: 0;
}

.step-title {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.step-desc {
  font-size: 0.8125rem;
  color: var(--muted-fg);
  margin-bottom: 20px;
}

/* ---- Inputs ---- */

.input-row {
  display: flex;
  gap: 16px;
}

.input-group {
  flex: 1;
}

.input-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-fg);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.input-with-unit {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition);
}

.input-with-unit:focus-within {
  border-color: var(--accent);
}

.input-with-unit input {
  flex: 1;
  border: none;
  outline: none;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 1.125rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  background: transparent;
  color: var(--fg);
  width: 0;
  min-width: 0;
}

.input-with-unit input::-webkit-inner-spin-button,
.input-with-unit input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.input-with-unit input[type="number"] {
  -moz-appearance: textfield;
}

.input-with-unit .unit {
  padding: 12px 16px 12px 0;
  font-size: 0.8125rem;
  color: var(--muted-fg);
  user-select: none;
}

.input-with-unit--small {
  width: 90px;
  flex-shrink: 0;
}

.input-with-unit--small input {
  padding: 8px 12px;
  font-size: 0.9375rem;
}

.input-with-unit--small .unit {
  padding: 8px 12px 8px 0;
}

/* ---- Toggle ---- */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.toggle-label {
  font-size: 0.875rem;
  color: var(--fg);
}

.toggle {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  border: none;
  background: var(--border);
  cursor: pointer;
  position: relative;
  transition: background var(--transition);
  outline: none;
}

.toggle[aria-checked="true"] {
  background: var(--accent);
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  transition: transform var(--spring);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle[aria-checked="true"] .toggle-thumb {
  transform: translateX(20px);
}

/* ---- Passepartout Options ---- */

.pp-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 400px;
  opacity: 1;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease,
              margin 0.4s ease;
}

.pp-options.collapsed {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin-top: -8px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ---- Slider ---- */

.slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--fg);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--fg);
  border: none;
  cursor: pointer;
}

/* ---- Color Swatches ---- */

.color-picker-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-fg);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.color-swatches {
  display: flex;
  gap: 8px;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  position: relative;
}

.color-swatch::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: border-color var(--transition);
}

.color-swatch.active::after {
  border-color: var(--fg);
}

.color-swatch:hover {
  transform: scale(1.1);
}

.pp-color-label {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---- Core Picker (Passepartout bevel core) ---- */

.core-picker-group {
  overflow: hidden;
  max-height: 80px;
  opacity: 1;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.25s ease,
              margin 0.35s ease;
}

.core-picker-group.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: -8px;
}

.core-picker-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-fg);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.core-options {
  display: flex;
  gap: 8px;
}

.core-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--muted-fg);
  cursor: pointer;
  transition: all var(--transition);
}

.core-option:hover {
  border-color: var(--border-hover);
  color: var(--fg);
}

.core-option.active {
  border-color: var(--accent);
  color: var(--fg);
  background: var(--muted);
}

.core-swatch {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ---- Option Cards (Glass) ---- */

.option-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-card {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  background: transparent;
  text-align: left;
  width: 100%;
  font-family: inherit;
  outline: none;
}

.option-card:hover {
  border-color: var(--border-hover);
  background: var(--muted);
}

.option-card.active {
  border-color: var(--accent);
  background: var(--muted);
}

.option-card-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  margin-right: 14px;
  flex-shrink: 0;
  position: relative;
  transition: border-color var(--transition);
}

.option-card.active .option-card-radio {
  border-color: var(--accent);
}

.option-card.active .option-card-radio::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.option-card-content {
  flex: 1;
}

.option-card-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
}

.option-card-desc {
  font-size: 0.75rem;
  color: var(--muted-fg);
  margin-top: 2px;
}

.option-card-price {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-fg);
  font-variant-numeric: tabular-nums;
  margin-left: 16px;
}

/* ---- Frame Grid ---- */

.frame-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.frame-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  background: transparent;
  text-align: left;
  font-family: inherit;
  outline: none;
}

.frame-card:hover {
  border-color: var(--border-hover);
  background: var(--muted);
}

.frame-card.active {
  border-color: var(--accent);
  background: var(--muted);
}

.frame-card-preview {
  width: 100%;
  height: 24px;
  border-radius: 3px;
  margin-bottom: 12px;
  background-repeat: repeat;
}

.frame-card-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
}

.frame-card-meta {
  font-size: 0.75rem;
  color: var(--muted-fg);
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
}

/* ---- Price Breakdown ---- */

.step--price {
  background: var(--muted);
  border: 1px solid var(--border);
}

.step--price:hover {
  border-color: var(--border);
}

.price-breakdown {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.price-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.price-label {
  font-size: 0.875rem;
  color: var(--fg);
  min-width: 100px;
}

.price-detail {
  flex: 1;
  font-size: 0.75rem;
  color: var(--muted-fg);
}

.price-value {
  font-size: 0.9375rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 80px;
  transition: all 0.3s ease;
}

.price-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.price-line--total .price-label {
  font-weight: 600;
  font-size: 1rem;
}

.price-line--total .price-value {
  font-size: 1.25rem;
  font-weight: 600;
}

/* ---- Share Button ---- */

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 20px;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
  cursor: pointer;
  transition: all var(--transition);
}

.share-btn:hover {
  background: white;
  border-color: var(--border-hover);
}

.share-btn-icon {
  flex-shrink: 0;
}

.share-btn.copied {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.share-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---- Animations ---- */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step {
  animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.step:nth-child(1) { animation-delay: 0.05s; }
.step:nth-child(2) { animation-delay: 0.1s; }
.step:nth-child(3) { animation-delay: 0.15s; }
.step:nth-child(4) { animation-delay: 0.2s; }
.step:nth-child(5) { animation-delay: 0.25s; }

/* Price value change flash */
.price-value.changed {
  color: var(--accent);
}

/* ---- Responsive ---- */

@media (max-width: 900px) {
  .calculator {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: relative;
    height: 50vh;
    padding: 24px;
  }

  .controls-panel {
    padding: 24px;
  }

  .header {
    padding: 16px 24px;
  }

  .frame-grid {
    grid-template-columns: 1fr;
  }
}
