/* ============================================================
   ATELIER MU 覺木工作室 — CMS Demo
   xunc.dev 作品集展示用：靜態頁 + 前端模擬 CMS 編輯模式
   ============================================================ */

:root {
  --color-bg: #f6f1e7;
  --color-bg-alt: #efe6d6;
  --color-surface: #fffcf6;
  --color-ink: #2c241b;
  --color-ink-soft: #5b4d3d;
  --color-wood: #8a5a3b;
  --color-wood-dark: #6b4226;
  --color-line: #ddd0ba;
  --color-cream: #fbf7ee;

  --tool-bg: #1c1a17;
  --tool-ink: #f4ede0;
  --tool-accent: #c98a4b;
  --tool-danger: #d16a5a;

  --radius-md: 10px;
  --radius-lg: 18px;
  --shadow-soft: 0 20px 45px -25px rgba(44, 36, 27, 0.45);
  --shadow-card: 0 12px 30px -18px rgba(44, 36, 27, 0.35);

  --font-serif: "Noto Serif TC", "Times New Roman", serif;
  --font-sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-sans);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  margin: 0;
  color: var(--color-ink);
}

p {
  margin: 0;
}

.eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--color-wood);
  font-weight: 500;
  margin-bottom: 14px;
}

.eyebrow--light {
  color: #f0e3c9;
}

/* ---------------- Demo banner ---------------- */

.demo-banner {
  background: var(--tool-bg);
  color: var(--tool-ink);
  font-size: 0.8rem;
  text-align: center;
  padding: 10px 16px;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

/* ---------------- Nav ---------------- */

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(20px, 5vw, 64px);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--color-line);
}

.brand {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.brand span {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--color-ink-soft);
  margin-left: 8px;
  letter-spacing: 0.1em;
}

.nav-links {
  display: flex;
  gap: clamp(16px, 3vw, 36px);
  font-size: 0.92rem;
}

.nav-links a {
  position: relative;
  padding-bottom: 4px;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--color-wood);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s var(--ease);
}

.nav-links a:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* ---------------- Hero ---------------- */

.hero {
  position: relative;
  min-height: 92vh;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.hero-image,
.philosophy-image,
.craft-image,
.product-image {
  position: relative;
  overflow: hidden;
}

.hero-image {
  position: absolute;
  inset: 0;
}

.hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(28, 22, 15, 0.15) 0%, rgba(20, 15, 10, 0.78) 92%);
}

.hero-content {
  position: relative;
  z-index: 2;
  color: #fbf3e4;
  padding: 0 clamp(20px, 6vw, 80px) clamp(56px, 8vw, 96px);
  max-width: 760px;
}

.hero-content h1 {
  color: #fbf3e4;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.3;
  margin-bottom: 20px;
}

.hero-subtitle {
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: #e9dcc2;
  max-width: 46ch;
  margin-bottom: 34px;
}

.cta-btn {
  display: inline-block;
  background: var(--color-cream);
  color: var(--color-wood-dark);
  padding: 14px 32px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  transition: transform 0.35s var(--ease), background 0.35s var(--ease);
}

.cta-btn:hover {
  background: #fff;
  transform: translateY(-2px);
}

/* ---------------- Section shared ---------------- */

main section {
  padding: clamp(64px, 10vw, 120px) clamp(20px, 6vw, 80px);
}

.section-head {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 56px;
}

.section-head h2 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

/* ---------------- Philosophy ---------------- */

.philosophy {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(32px, 6vw, 80px);
  align-items: center;
  background: var(--color-bg-alt);
}

.philosophy-image {
  border-radius: var(--radius-lg);
  aspect-ratio: 4 / 5;
  box-shadow: var(--shadow-card);
}

.philosophy-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.philosophy-text h2 {
  font-size: clamp(1.6rem, 2.8vw, 2.2rem);
  margin-bottom: 22px;
}

.philosophy-text p.editable-text {
  color: var(--color-ink-soft);
  font-size: 1.02rem;
  max-width: 52ch;
}

/* ---------------- Products ---------------- */

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: clamp(24px, 3vw, 36px);
  max-width: 1200px;
  margin: 0 auto;
}

.product-card {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.4s var(--ease), opacity 0.4s var(--ease);
}

.product-card:hover {
  transform: translateY(-6px);
}

.product-image {
  aspect-ratio: 1 / 1;
  background: var(--color-bg-alt);
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-info {
  padding: 20px 22px 26px;
}

.product-info h3 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.price {
  color: var(--color-wood);
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.hidden-badge {
  display: none;
  position: absolute;
  top: 14px;
  left: 14px;
  background: var(--tool-danger);
  color: #fff;
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: 999px;
  letter-spacing: 0.03em;
  z-index: 5;
}

.visibility-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 6;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(28, 26, 23, 0.55);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(2px);
  transition: background 0.25s var(--ease);
}

.visibility-toggle:hover {
  background: rgba(28, 26, 23, 0.85);
}

.visibility-toggle::before {
  content: "";
  width: 18px;
  height: 18px;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'><path d='M1 12s4-7 11-7 11 7 11 7-4 7-11 7-11-7-11-7z'/><circle cx='12' cy='12' r='3'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'><path d='M1 12s4-7 11-7 11 7 11 7-4 7-11 7-11-7-11-7z'/><circle cx='12' cy='12' r='3'/></svg>");
}

.visibility-toggle[aria-pressed="false"]::before {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'><path d='M17.94 17.94A10.94 10.94 0 0 1 12 19c-7 0-11-7-11-7a21.6 21.6 0 0 1 5.06-5.94M9.9 4.24A10.4 10.4 0 0 1 12 4c7 0 11 7 11 7a21.6 21.6 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24'/><path d='M1 1l22 22'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'><path d='M17.94 17.94A10.94 10.94 0 0 1 12 19c-7 0-11-7-11-7a21.6 21.6 0 0 1 5.06-5.94M9.9 4.24A10.4 10.4 0 0 1 12 4c7 0 11 7 11 7a21.6 21.6 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24'/><path d='M1 1l22 22'/></svg>");
}

/* ---------------- Craft ---------------- */

.craft {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(32px, 6vw, 80px);
  align-items: center;
}

.craft-image {
  order: 2;
  border-radius: var(--radius-lg);
  aspect-ratio: 4 / 5;
  box-shadow: var(--shadow-card);
}

.craft-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.craft-text {
  order: 1;
}

.craft-text h2 {
  font-size: clamp(1.6rem, 2.8vw, 2.2rem);
  margin-bottom: 22px;
}

.craft-text p.editable-text:first-of-type {
  color: var(--color-ink-soft);
  max-width: 52ch;
  margin-bottom: 24px;
}

.craft-quote {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--color-wood-dark);
  border-left: 3px solid var(--color-wood);
  padding-left: 18px;
}

/* ---------------- Footer ---------------- */

footer {
  background: var(--tool-bg);
  color: var(--tool-ink);
  padding: clamp(48px, 8vw, 80px) clamp(20px, 6vw, 80px) 28px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 40px;
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: 36px;
  border-bottom: 1px solid rgba(244, 237, 224, 0.15);
}

.footer-logo {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  margin-bottom: 10px;
}

.footer-tagline {
  color: #cbb996;
  max-width: 32ch;
}

.footer-info p {
  margin-bottom: 10px;
  color: #e6dcc7;
  font-size: 0.95rem;
}

.footer-label {
  display: inline-block;
  width: 70px;
  color: #a08c68;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
}

.footer-copyright {
  max-width: 1200px;
  margin: 20px auto 0;
  font-size: 0.78rem;
  color: #8a7c63;
}

/* ============================================================
   CMS 編輯模式
   ============================================================ */

.cms-launcher {
  position: fixed;
  right: clamp(16px, 3vw, 32px);
  bottom: clamp(16px, 3vw, 32px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.cms-edit-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--tool-bg);
  color: var(--tool-ink);
  border: none;
  padding: 15px 22px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.3s var(--ease), background 0.3s var(--ease);
}

.cms-edit-btn:hover {
  transform: translateY(-3px);
  background: #2a2621;
}

.cms-edit-btn-icon {
  font-size: 1rem;
}

body.cms-edit-mode .cms-edit-btn {
  background: var(--tool-accent);
  color: #241a0f;
}

/* 引導氣泡 */

.onboard-bubble {
  position: relative;
  background: var(--color-surface);
  color: var(--color-ink);
  font-size: 0.85rem;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  max-width: 220px;
  text-align: center;
  animation: bubble-float 2.6s ease-in-out infinite;
}

.onboard-bubble[hidden] {
  display: none;
}

.onboard-bubble-arrow {
  position: absolute;
  bottom: -6px;
  right: 28px;
  width: 12px;
  height: 12px;
  background: var(--color-surface);
  transform: rotate(45deg);
}

@keyframes bubble-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* 頂部工具列 */

.cms-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--tool-bg);
  color: var(--tool-ink);
  padding: 14px clamp(16px, 4vw, 40px);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.5);
  transform: translateY(-110%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.45s var(--ease), opacity 0.35s var(--ease);
}

body.cms-edit-mode .cms-toolbar {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toolbar-label {
  font-weight: 600;
  letter-spacing: 0.03em;
  background: var(--tool-accent);
  color: #241a0f;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar-btn {
  border: 1px solid rgba(244, 237, 224, 0.25);
  background: transparent;
  color: var(--tool-ink);
  padding: 9px 18px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  cursor: pointer;
  transition: background 0.25s var(--ease), transform 0.25s var(--ease), border-color 0.25s var(--ease);
  white-space: nowrap;
}

.toolbar-btn:hover {
  transform: translateY(-1px);
}

.toolbar-btn--primary {
  background: var(--tool-accent);
  border-color: var(--tool-accent);
  color: #241a0f;
  font-weight: 500;
}

.toolbar-btn--primary:hover {
  background: #dba05e;
}

.toolbar-btn--danger {
  border-color: var(--tool-danger);
  color: #ffd9d0;
}

.toolbar-btn--danger:hover {
  background: rgba(209, 106, 90, 0.18);
}

.toolbar-btn--ghost:hover {
  background: rgba(244, 237, 224, 0.1);
}

/* 可編輯文字：非編輯模式下完全無感 */

body.cms-edit-mode .editable-text {
  outline: 1.5px dashed rgba(138, 90, 59, 0.55);
  outline-offset: 4px;
  border-radius: 4px;
  cursor: text;
  transition: background 0.2s var(--ease), outline-color 0.2s var(--ease);
}

body.cms-edit-mode .editable-text:hover {
  background: rgba(201, 138, 75, 0.12);
}

body.cms-edit-mode .editable-text:focus {
  outline: 1.5px solid var(--color-wood);
  background: rgba(201, 138, 75, 0.18);
}

/* 圖片更換遮罩 */

.image-edit-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 16, 10, 0.45);
  opacity: 0;
  transition: opacity 0.25s var(--ease);
  z-index: 4;
}

body.cms-edit-mode .image-edit-overlay {
  display: flex;
}

body.cms-edit-mode [data-image-key]:hover .image-edit-overlay {
  opacity: 1;
}

.image-edit-btn {
  background: var(--color-cream);
  color: var(--color-wood-dark);
  border: none;
  padding: 10px 20px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

/* 商品顯示/隱藏 */

body.cms-edit-mode .visibility-toggle {
  display: flex;
}

body.cms-edit-mode .product-card.is-hidden {
  opacity: 0.4;
}

body.cms-edit-mode .product-card.is-hidden .hidden-badge {
  display: inline-block;
}

body:not(.cms-edit-mode) .product-card.is-hidden {
  display: none;
}

/* 編輯模式時整體頁面往下推，避免被工具列蓋住 */

body.cms-edit-mode {
  padding-top: 58px;
}

body.cms-edit-mode .site-nav {
  top: 58px;
}

/* ---------------- Modal ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(20, 16, 10, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-panel {
  position: relative;
  background: var(--color-surface);
  color: var(--color-ink);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-soft);
}

.modal-panel--small {
  max-width: 420px;
}

.modal-panel h3 {
  font-size: 1.3rem;
  margin-bottom: 10px;
}

.modal-desc {
  color: var(--color-ink-soft);
  font-size: 0.92rem;
  margin-bottom: 20px;
}

.modal-url-row {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}

#image-url-input {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--color-line);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  background: #fff;
  color: var(--color-ink);
}

#image-url-input:focus {
  outline: 2px solid var(--color-wood);
  outline-offset: 1px;
}

.modal-preset-label {
  font-size: 0.82rem;
  color: var(--color-ink-soft);
  margin-bottom: 10px;
  letter-spacing: 0.03em;
}

.image-preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.image-preset-grid button {
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  background: var(--color-bg-alt);
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.image-preset-grid button:hover {
  border-color: var(--color-wood);
  transform: scale(1.03);
}

.image-preset-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--color-bg-alt);
  color: var(--color-ink);
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  background: var(--color-line);
}

.modal-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-confirm-actions .toolbar-btn {
  color: var(--color-ink);
}

.modal-confirm-actions .toolbar-btn--ghost {
  border-color: var(--color-line);
}

.modal-confirm-actions .toolbar-btn--ghost:hover {
  background: var(--color-bg-alt);
}

.modal-confirm-actions .toolbar-btn--danger {
  color: #fff;
  background: var(--tool-danger);
  border-color: var(--tool-danger);
}

.modal-confirm-actions .toolbar-btn--danger:hover {
  background: #b8503f;
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translate(-50%, 20px);
  background: var(--tool-bg);
  color: var(--tool-ink);
  padding: 14px 26px;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-soft);
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast::before {
  content: "✓ ";
  color: var(--tool-accent);
}

/* ============================================================
   RWD
   ============================================================ */

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

  .craft-image,
  .craft-text {
    order: initial;
  }

  .philosophy-image,
  .craft-image {
    aspect-ratio: 16 / 10;
  }

  .cms-toolbar {
    flex-wrap: wrap;
  }

  .toolbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .site-nav {
    padding: 16px 20px;
  }

  .nav-links {
    gap: 14px;
    font-size: 0.82rem;
  }

  .brand span {
    display: none;
  }

  .hero {
    min-height: 100vh;
  }

  .cms-edit-btn-text {
    display: none;
  }

  .cms-edit-btn {
    padding: 15px;
  }

  .onboard-bubble {
    max-width: 170px;
    font-size: 0.78rem;
  }

  .footer-info p {
    font-size: 0.88rem;
  }

  .modal-panel {
    padding: 24px 20px;
  }
}

@media (max-width: 420px) {
  .toolbar-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .toolbar-label {
    font-size: 0.78rem;
    padding: 5px 10px;
  }
}

/* ============================================================
   減少動態偏好
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .onboard-bubble {
    animation: none;
  }
}
