/* Styles for the HTML fragments app.js injects via .innerHTML template
   strings (renderResults/renderHouseResults, renderMaterialsSection,
   buildMaterialsModalBodyHTML, renderStageStepper/renderHouseStageStepper,
   renderConceptPreviewShell) plus a couple of state classes app.js toggles
   via classList (is-dragover, is-changing, is-revealed). These can't be
   Tailwind utility classes because app.js builds them as plain semantic
   class-name strings, independent of any CSS framework - see CLAUDE.md's
   "Frontend" section for the full reasoning. Everything else in index.html/
   login.html/signup.html is plain Tailwind CDN utilities, not this file.

   Colors below are the literal "Sage & Linen" theme hex values (soft beige/
   mint palette, replacing the earlier dark Aurelian Monolith system) -
   hardcoded because this plain CSS file has no access to the Tailwind config
   object defined inline in each HTML page. Keep these in sync with the
   `colors`/`fontFamily` values in index.html/login.html/signup.html's inline
   tailwind.config scripts if the theme changes again. */

/* Tailwind utility classes (e.g. "flex") are author-origin CSS, so they beat
   the browser UA stylesheet's [hidden]{display:none} rule at equal
   specificity (author > user-agent, tie-break doesn't apply across origins).
   Without this, any element that combines the native hidden ATTRIBUTE
   (toggled by app.js via el.hidden = true/false - e.g. #lightbox,
   #materials-modal-overlay) with a Tailwind "flex"/"grid"/"block" class for
   its shown state would render visible even while hidden. This one rule
   makes [hidden] always win, everywhere, without touching app.js or markup. */
/* Material Symbols is a variable font (weight/fill/grade/optical-size axes) -
   without pinning them, the same icon (e.g. the "close" X used on
   remove-photo-btn/lightbox-close/materials-modal-close) can render with a
   different stroke weight/shape depending on context (noticeably chunkier
   inside a small hover-scaled circular button), since the browser is free to
   interpolate the unset axes however it likes. Pinning to a fixed, thin,
   unfilled outline keeps every icon the same shape everywhere. */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Chrome shows an I-beam text cursor over any plain text by default, which
   reads as "this is an editable field" even on static copy (headings,
   pricing card text, nav labels...) - disabling selection site-wide makes
   Chrome fall back to a normal pointer/arrow cursor over that text instead.
   Real form fields are unaffected: browsers give <input>/<textarea>/
   [contenteditable] their own selection behavior regardless of an ancestor's
   user-select, so typing/selecting inside the upload forms still works
   normally - re-declared explicitly below anyway for clarity, not because
   it's strictly required. */
body {
  user-select: none;
  -webkit-user-select: none;
}

input, textarea, [contenteditable] {
  user-select: text;
  -webkit-user-select: text;
}

[hidden] {
  display: none !important;
}

/* Defense-in-depth against horizontal scroll on mobile: the actual overflow
   source (a mismatched padding/negative-margin pair on #hero-copy) is fixed
   at its root cause in index.html, but this stays as a safety net against a
   future layout regression re-introducing sub-viewport-width overflow -
   nothing in this app relies on horizontal page scroll, so it never clips
   real content, only accidental overflow. */
html, body {
  overflow-x: hidden;
}

:root {
  --ink: #33362e;
  --ink-soft: #6e6c5c;
  --paper: #ffffff;
  --paper-raised: #f5efe2;
  --paper-high: #efe7d6;
  --line: rgba(122, 71, 18, 0.18);
  --accent: #7A4712;
  --accent-bg: rgba(122, 71, 18, 0.1);
  --accent-dark: #4A2F10;
  --on-accent: #ffffff;
  --shadow: 0 12px 32px rgba(51, 54, 46, 0.1), 0 2px 8px rgba(51, 54, 46, 0.05);
  --shadow-lift: 0 24px 56px rgba(51, 54, 46, 0.14), 0 4px 16px rgba(51, 54, 46, 0.08);
}

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

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

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

/* ---- Tab bar active state ---- */
/* switchTab() (app.js) only toggles the plain "is-active" class - the visual
   active/inactive look lives here, not as static Tailwind utilities in the
   markup, so switching tabs actually changes which button looks active. */

/* Nav now lives in a permanently-dark glass pill (see header in index.html) -
   colors are light-on-dark regardless of which tab/page is active underneath,
   so the header reads consistently everywhere ("ambience throughout"). */
.tab-btn {
  background: none;
  border: none;
  color: #c9bfa6; /* on-night-variant */
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.2s ease, transform 0.15s ease;
}

.tab-btn:hover {
  color: #f5efe2; /* on-night */
  transform: translateY(-1px);
}

.tab-btn.is-active {
  color: #1c1815; /* night - dark text over the sliding pill (#tab-active-pill), not the green accent */
}

/* Sliding active-tab pill (index.html's #tab-active-pill) - its left/width
   are animated in app.js (moveTabActivePill) to track whichever tab is
   active, rather than each button drawing its own static background. */
#tab-active-pill {
  transition: left 0.35s cubic-bezier(0.16, 1, 0.3, 1), width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- History modal tabs (light surface, not the dark nav pill) ---- */
.history-tab-btn {
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.2s ease, border-color 0.15s ease;
}

.history-tab-btn:hover {
  color: var(--ink);
}

.history-tab-btn.is-active {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

/* ---- Subscription plan UI (Chunk 4) ---- */
/* Kaggle/OpenAI model-choice toggle (Room Redesign) - setModelToggleValue()
   in app.js toggles this class, the visual selected/unselected look lives
   here, matching the .tab-btn.is-active pattern above. */
.model-toggle-btn {
  cursor: pointer;
  background: transparent;
}

.model-toggle-btn.is-active {
  border-color: var(--accent) !important;
  background: rgba(122, 71, 18, 0.08);
}

/* Pricing tab - highlights whichever plan card matches the logged-in user's
   real plan (applyPricingUI() in app.js), on top of the "Most Popular"
   static badge Pro already has in the markup. */
.pricing-card-current {
  box-shadow: 0 0 0 2px var(--accent) inset;
}

/* Per-user quota usage bars (nav account dropdown + mobile sidebar) -
   renderPlanUsage()/planUsageRow() in app.js build these fragments. Sage
   fill on a faint track, matching the site's accent color everywhere else. */
.plan-usage-bar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.plan-usage-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* ---- Scroll reveal ---- */

[data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1), transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-reveal].is-revealed {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---- Dropzone drag state ---- */

.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

/* ---- Progress message/subtitle fade ---- */

.progress-message,
.progress-subtitle {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.progress-message.is-changing {
  opacity: 0;
  transform: translateY(4px);
}

.progress-subtitle.is-changing {
  opacity: 0;
}

/* ---- Stage stepper ---- */

.stage-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
}

.stage-icon {
  position: relative;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  transition: border-color 0.25s ease, background 0.25s ease;
}

.stage-icon::after {
  content: "";
  position: absolute;
  top: 48%;
  left: 50%;
  width: 8px;
  height: 5px;
  border-left: 2px solid var(--on-accent);
  border-bottom: 2px solid var(--on-accent);
  transform: translate(-50%, -60%) rotate(-45deg) scale(0);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stage-item.is-done .stage-icon {
  background: var(--accent);
  border-color: var(--accent);
}

.stage-item.is-done .stage-icon::after {
  transform: translate(-50%, -60%) rotate(-45deg) scale(1);
}

.stage-item.is-active .stage-icon {
  border-color: var(--accent);
}

.stage-item.is-active .stage-icon::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 2px solid var(--accent-bg);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.stage-label {
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  line-height: 1.3;
  transition: color 0.25s ease;
}

.stage-item.is-done .stage-label,
.stage-item.is-active .stage-label {
  color: var(--ink);
}

/* ---- Concept previews ---- */

.concept-card {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper);
}

.concept-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, var(--paper) 30%, var(--paper-high) 50%, var(--paper) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  transition: opacity 0.4s ease;
}

.concept-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  filter: blur(10px);
  transform: scale(1.04);
  transition: opacity 0.6s ease, filter 0.6s ease, transform 0.6s ease;
}

.concept-card.is-resolved .concept-skeleton {
  opacity: 0;
  pointer-events: none;
}

.concept-card.is-resolved .concept-img {
  opacity: 1;
  filter: blur(0);
  transform: scale(1);
}

/* ---- Generic skeleton loading blocks ----
   Same shimmer technique as .concept-skeleton above, generalized so it can
   be dropped anywhere content is still loading (history modal, admin user
   table, nav account-menu usage bars) - combine with Tailwind sizing
   utilities (h-*, w-*, rounded-*) for the actual shape, this class only
   supplies the animated gradient. Two variants: the light-surface one for
   modals/cards sitting on the cream "paper" background, and the dark one
   for the nav's permanently-dark glass pill/dropdown + mobile sidebar. */
.skeleton-shimmer {
  /* Deliberately NOT var(--paper-high)/var(--paper-raised) - those are
     nearly identical to the surface-container background these skeletons
     usually sit on (both resolve to ~#efe7d6), which made the very first
     version of this almost invisible against the history modal. #ddd0b0 is
     close to the theme's own surface-container-highest token, giving real
     contrast against white, linen, AND surface-container backgrounds alike. */
  background: linear-gradient(100deg, #ddd0b0 25%, var(--paper-raised) 50%, #ddd0b0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

.skeleton-shimmer-dark {
  background: linear-gradient(
    100deg,
    rgba(245, 239, 226, 0.08) 25%,
    rgba(245, 239, 226, 0.22) 50%,
    rgba(245, 239, 226, 0.08) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

.concept-label {
  position: absolute;
  bottom: 0.4rem;
  left: 0.4rem;
  margin: 0;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--on-accent);
  background: var(--accent);
  padding: 0.15rem 0.4rem;
}

/* ---- Result cards (room + house results grids) ---- */

.results {
  animation: fade-up 0.5s ease both;
}

.result-card {
  background: var(--paper);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.result-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
  border-color: var(--accent);
}

.result-card .img-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--paper-raised);
}

.result-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.result-card:hover img {
  transform: scale(1.04);
}

.download-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(14, 14, 14, 0.7);
  backdrop-filter: blur(4px);
  color: var(--paper);
  box-shadow: var(--shadow);
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.download-btn svg {
  width: 17px;
  height: 17px;
}

.download-btn:hover,
.download-btn:focus-visible {
  background: var(--accent);
  color: var(--on-accent);
  transform: scale(1.08);
}

.result-card .caption {
  padding: 0.9rem 1rem 1.1rem;
  text-align: center;
}

.result-card .tier-name {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.result-card .tier-desc {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

/* ---- Materials note / open button (inside result-card) ---- */

.materials-note {
  margin: 0.7rem 1rem 1.1rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: center;
  cursor: default;
}

.materials-note-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.materials-spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

/* ---- Materials retry loading bar (inside the materials modal body) ---- */

@keyframes materials-retry-indeterminate {
  0% {
    left: -35%;
  }
  100% {
    left: 100%;
  }
}

.materials-retry-progress {
  margin: 0.5rem 1rem 0;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
  position: relative;
}

.materials-retry-progress::after {
  content: "";
  position: absolute;
  top: 0;
  left: -35%;
  height: 100%;
  width: 35%;
  background: var(--accent);
  border-radius: 2px;
  animation: materials-retry-indeterminate 1.1s ease-in-out infinite;
}

.materials-retry-hint {
  margin: 0.4rem 1rem 1.1rem;
  font-size: 0.72rem;
  color: var(--ink-soft);
  text-align: center;
}

.materials-open-btn {
  display: block;
  width: calc(100% - 2rem);
  margin: 0.7rem 1rem 1.1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
  background: none;
  border-left: none;
  border-right: none;
  border-bottom: none;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: "Poppins", sans-serif;
  color: var(--accent);
  text-align: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.materials-open-btn:hover {
  color: var(--accent-dark);
  background: var(--accent-bg);
}

/* ---- Materials table (inside the materials modal body) ---- */

.materials-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: fixed;
}

.materials-table th {
  text-align: left;
  padding: 0.4rem 0.5rem;
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  opacity: 0.85;
  border-bottom: 1px solid var(--line);
}

.materials-table td {
  padding: 0.7rem 0.5rem;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
  overflow-wrap: break-word;
  word-break: break-word;
}

.materials-table tr:last-child td {
  border-bottom: none;
}

.material-name {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.material-spec {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.45;
}

.material-price {
  color: var(--ink);
  line-height: 1.5;
}

.material-source a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-word;
}

.material-source a:hover {
  text-decoration: underline;
}

.estimate-badge {
  display: inline-block;
  margin-top: 0.3rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.materials-total {
  margin: 1rem 0 0;
  text-align: right;
  font-size: 0.9rem;
  color: var(--ink);
}

@media (max-width: 480px) {
  .materials-table,
  .materials-table thead,
  .materials-table tbody,
  .materials-table tr {
    display: block;
    width: 100%;
  }

  .materials-table thead {
    display: none;
  }

  .materials-table tr {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--line);
  }

  .materials-table tr:last-child {
    border-bottom: none;
  }

  .materials-table td {
    display: block;
    padding: 0.2rem 0;
    border-bottom: none;
  }

  .material-price::before {
    content: "Price: ";
    color: var(--ink-soft);
    font-size: 0.72rem;
  }

  .material-source::before {
    content: "Source: ";
    color: var(--ink-soft);
    font-size: 0.72rem;
  }
}
