/* Pergola designer (functions/pergola-designer.php). Same colors as the site's modern design. */

:root {
  --cream: #f5f7fa;
  --paper: #fff;
  --sand: #eef2f6;
  --line: #e1e6ec;
  --ink: #1b2330;
  --ink-soft: #4d5868;
  --ink-faint: #7a8595;
  --forest: #3c8231;
  --forest-dark: #326e29;
  --forest-soft: #e8f3e5;
  --radius: 14px;
  --radius-sm: 8px;
  --top: 56px;
  --panel: 380px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--cream);
  color: var(--ink);
  font: 15px/1.5 "Plus Jakarta Sans", system-ui, sans-serif;
}

button {
  font: inherit;
  color: inherit;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.pd {
  display: grid;
  grid-template-columns: 1fr var(--panel);
  grid-template-rows: var(--top) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* Top bar */
.pd-top {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.pd-logo {
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
}

.pd-title {
  font-weight: 600;
  color: var(--ink-soft);
}

.pd-badge {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--forest-soft);
  color: var(--forest-dark);
  font-size: 12px;
  font-weight: 700;
}

.pd-back {
  margin-left: auto;
  color: var(--ink-soft);
  font-weight: 600;
  text-decoration: none;
}

.pd-back:hover {
  color: var(--forest);
}

/* 3D view */
.pd-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.pd-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.pd-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(17, 24, 39, 0.08);
  font-size: 13px;
  color: var(--ink-soft);
  pointer-events: none;
}

.pd-hud strong {
  font-size: 20px;
  color: var(--ink);
}

.pd-views {
  position: absolute;
  left: 50%;
  bottom: 16px;
  display: flex;
  gap: 4px;
  padding: 4px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(17, 24, 39, 0.1);
}

.pd-views button {
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: none;
  font-weight: 600;
  cursor: pointer;
}

.pd-views button:hover {
  background: var(--sand);
}

.pd-views button.is-active {
  background: var(--ink);
  color: #fff;
}

/* Options panel */
.pd-panel {
  overflow-y: auto;
  background: var(--paper);
  border-left: 1px solid var(--line);
}

.pd-group {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.pd-group h2 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--forest);
}

.pd-field + .pd-field,
.pd-seg + .pd-field {
  margin-top: 16px;
}

.pd-label {
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.pd-hint {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-faint);
}

/* Segmented buttons */
.pd-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--sand);
  border-radius: var(--radius-sm);
}

/* Natural width, sharing any spare room, wrapping when a row is full */
.pd-seg button {
  flex: 1 0 auto;
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: none;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.pd-seg button:hover:not(:disabled):not([aria-disabled="true"]) {
  background: rgba(255, 255, 255, 0.6);
}

.pd-seg button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--forest-dark);
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.12);
}

.pd-seg button:disabled,
.pd-seg button[aria-disabled="true"] {
  color: var(--ink-faint);
  cursor: not-allowed;
}

.pd-seg button:disabled {
  opacity: 0.45;
}

/* Ruled out by another choice: greyed, with an i; hover or tap for why (designer.js showWhy) */
.pd-seg button[aria-disabled="true"] {
  color: rgba(77, 88, 104, 0.5);
}

.pd-why-i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 5px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  font: italic 700 10px/1 Georgia, serif;
  vertical-align: 1px;
  color: var(--ink-faint);
}

.pd-tip {
  position: fixed;
  z-index: 1000;
  max-width: 240px;
  padding: 8px 11px;
  border-radius: 8px;
  background: #1b2330;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.25);
  pointer-events: none;
}

/* Sliders */
.pd-range {
  display: block;
}

.pd-range + .pd-range {
  margin-top: 14px;
}

.pd-range-head {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
}

.pd-range-head output {
  font-weight: 800;
  color: var(--forest-dark);
}

.pd-range input {
  width: 100%;
  margin: 6px 0 0;
  accent-color: var(--forest);
}

.pd-range-ends {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-faint);
}

/* Paint swatches */
.pd-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pd-swatch {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.15);
  cursor: pointer;
}

.pd-swatch[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.15), 0 0 0 2px var(--paper), 0 0 0 4px var(--forest);
}

.pd-swatch-custom {
  display: inline-block;
  background: conic-gradient(#e74c3c, #f1c40f, #2ecc71, #3498db, #9b59b6, #e74c3c);
}

.pd-swatch-custom::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 2px #fff;
}

.pd-swatch-custom input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* End cuts */
.pd-cuts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.pd-cuts button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.pd-cuts button:hover {
  border-color: var(--ink-faint);
}

.pd-cuts button[aria-pressed="true"] {
  border-color: var(--forest);
  background: var(--forest-soft);
  color: var(--forest-dark);
}

.pd-cuts svg {
  width: 100%;
  max-width: 84px;
  height: 30px;
  fill: #c9a27a;
}

.pd-cuts button[aria-pressed="true"] svg {
  fill: var(--forest);
}

/* Lumber list */
.pd-list {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.pd-list th {
  padding: 0 6px 6px 0;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  color: var(--ink-faint);
}

.pd-list td {
  padding: 8px 6px 8px 0;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.pd-list td:first-child {
  width: 40px;
  font-weight: 800;
}

.pd-list small {
  display: block;
  color: var(--ink-faint);
}

.pd-notes {
  margin: 12px 0 0;
  padding: 10px 12px 10px 28px;
  background: #fff7e6;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #7a5310;
}

/* Actions */
.pd-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.pd-btn {
  flex: 1 1 auto;
  min-height: 42px;
  padding: 8px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--forest);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.pd-btn:hover {
  background: var(--forest-dark);
}

.pd-btn-quiet {
  flex: 0 0 auto;
  background: var(--sand);
  color: var(--ink);
}

.pd-btn-quiet:hover {
  background: var(--line);
}

:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

/* Phones and small tablets: model on top, options below */
@media (max-width: 860px) {
  .pd {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .pd-top {
    position: sticky;
    top: 0;
    z-index: 2;
    flex: none;
    height: var(--top);
    padding: 0 16px;
  }

  .pd-title {
    display: none;
  }

  .pd-stage {
    position: sticky;
    top: var(--top);
    z-index: 1;
    flex: none;
    height: 48vh;
    border-bottom: 1px solid var(--line);
  }

  .pd-hud {
    top: 10px;
    left: 10px;
    padding: 8px 12px;
  }

  .pd-hud span:nth-child(n + 3) {
    display: none;
  }

  .pd-hud strong {
    font-size: 17px;
  }

  .pd-views {
    bottom: 10px;
  }

  .pd-views button {
    padding: 6px 12px;
  }

  .pd-panel {
    border-left: 0;
  }

  .pd-group {
    padding: 18px 16px;
  }
}

/* Brace previews: post and beam in gray, the brace in wood color */
.pd-cuts svg .pd-ghost {
  fill: #d5dae1;
}

.pd-cuts button[aria-pressed="true"] svg .pd-ghost {
  fill: #b9cdb4;
}

.pd-hint-top {
  margin: -6px 0 12px;
}

/* Price estimate */
.pd-estimate {
  background: var(--cream);
}

.pd-price {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.pd-costs {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 14px;
}

.pd-costs td {
  padding: 5px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
}

.pd-costs td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.pd-costs-total td {
  font-weight: 800;
  color: var(--ink);
}

.pd-prices {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

.pd-prices summary {
  padding: 10px 14px;
  font-weight: 700;
  color: var(--forest-dark);
  cursor: pointer;
}

.pd-prices[open] {
  padding-bottom: 14px;
}

.pd-prices[open] summary {
  border-bottom: 1px solid var(--line);
}

.pd-prices fieldset {
  margin: 0;
  padding: 12px 14px 0;
  border: 0;
}

.pd-prices legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.pd-price-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  font-size: 14px;
}

.pd-price-field input {
  width: 92px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  text-align: right;
}

.pd-price-field input:focus {
  border-color: var(--forest);
  outline: none;
}

.pd-prices .pd-buttons,
.pd-prices .pd-hint {
  margin-left: 14px;
  margin-right: 14px;
}

.pd-hud-price {
  font-weight: 800;
  color: var(--forest-dark) !important;
}

.pd-hint + .pd-field {
  margin-top: 14px;
}

/* Steps: a numbered bar on top, one step's settings, Back / Next at the bottom */
.pd-panel {
  display: flex;
  flex-direction: column;
}

.pd-steps {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 10px 8px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.pd-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 6px 2px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
}

.pd-step:hover {
  background: var(--sand);
}

.pd-step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--sand);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.pd-step-label {
  max-width: 100%;
  overflow: hidden;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-faint);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pd-step.is-done .pd-step-num {
  background: var(--forest-soft);
  color: var(--forest-dark);
}

.pd-step.is-current .pd-step-num {
  background: var(--forest);
  color: #fff;
}

.pd-step.is-current .pd-step-label {
  color: var(--ink);
}

.pd-step-body {
  flex: 1 0 auto;
}

.pd-step-nav {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.pd-step-nav .pd-btn {
  flex: 0 0 auto;
}

.pd-step-total {
  font-weight: 800;
  color: var(--forest-dark);
}

@media (max-width: 860px) {
  /* The page scrolls on phones, so the bars pin to the screen, under the pinned 3D view */
  .pd-panel {
    overflow: visible;
  }

  .pd-steps {
    top: calc(var(--top) + 48vh);
  }
}

.pd-field + .pd-range {
  margin-top: 16px;
}

/* Starts a new line of option buttons (a new group) */
.pd-seg-break {
  flex-basis: 100%;
  height: 0;
}

/* Links styled as buttons (the request view) */
a.pd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.pd-back + .pd-back {
  margin-left: 16px;
}

/* The design in words: the quote step and the request view */
.pd-spec {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: 14px;
}

.pd-spec dt {
  font-weight: 600;
  color: var(--ink-faint);
}

.pd-spec dd {
  margin: 0;
  color: var(--ink);
}

/* Quote request form (visitors) */
.pd-quote {
  background: var(--cream);
}

.pd-intro {
  margin-top: 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.pd-input {
  display: block;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.pd-input .pd-label em {
  font-style: normal;
  font-weight: 500;
  color: var(--ink-faint);
}

.pd-input input:not([type="radio"]):not([type="file"]),
.pd-input textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font: inherit;
  font-size: 16px; /* no zoom on iPhone */
  color: var(--ink);
}

.pd-input textarea {
  resize: vertical;
}

.pd-input input:focus,
.pd-input textarea:focus {
  border-color: var(--forest);
  outline: none;
  box-shadow: 0 0 0 3px var(--forest-soft);
}

.pd-input input[type="file"] {
  max-width: 100%;
  font-size: 14px;
}

.pd-input.is-invalid input,
.pd-input.is-invalid textarea {
  border-color: #c0392b;
}

.pd-error {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: #c0392b;
}

.pd-error[hidden],
.pd-form-error[hidden] {
  display: none;
}

.pd-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pd-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pd-choice span {
  display: inline-block;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.pd-choice input:checked + span {
  border-color: var(--forest);
  background: var(--forest-soft);
  color: var(--forest-dark);
}

.pd-choice input:focus-visible + span {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

.pd-trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.pd-form-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fdecea;
  color: #8e2a1f;
  font-size: 14px;
}

.pd-btn-wide {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
}

.pd-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.pd-quote-done p {
  margin: 0 0 10px;
}

.pd-big {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
}

.pd-quote-done a {
  color: var(--forest-dark);
  font-weight: 700;
}

/* A sent request (admins): who sent it */
.pd-eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--forest);
}

.pd-request h1 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.25;
}

.pd-request .pd-hint {
  margin-top: 2px;
}

/* Just the 3D view, in the lead's box in the admin */
.pd.is-embed {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.pd.is-embed .pd-top,
.pd.is-embed .pd-panel {
  display: none;
}

.pd.is-embed .pd-hud {
  top: 10px;
  left: 10px;
  padding: 8px 12px;
}

.pd.is-embed .pd-hud strong {
  font-size: 17px;
}

.pd.is-embed .pd-views {
  bottom: 10px;
}

@media (max-width: 860px) {
  .pd.is-embed {
    display: grid;
    height: 100vh;
  }

  .pd.is-embed .pd-stage {
    position: relative;
    top: 0;
    height: 100%;
  }

  .pd-back + .pd-back {
    display: none;
  }
}

.pd-input legend {
  padding: 0;
}

h1.pd-title {
  margin: 0;
  font-size: inherit;
  line-height: inherit;
}
