/* Trip Studio：延續大阪片配色的紙感介面。主要使用者在手機上，字大、按鈕大、不花俏。 */

:root {
  --paper: #f7f6f2;
  --paper-deep: #efece4;
  --surface: #ffffff;
  --ink: #1d2430;
  --ink-soft: #4a5363;
  --ink-faint: #6b7280;
  --indigo: #223a5e;
  --indigo-deep: #182a45;
  --indigo-tint: #e6ebf3;
  --shu: #e07a62;
  --shu-ink: #a8432c;      /* 朱色文字：在白底上對比足夠 */
  --shu-tint: #fbebe6;
  --ok: #3f6b4f;
  --wrap-yellow: #ffd23f;
  --line: #ddd8cc;

  --font-sans: "PingFang TC", -apple-system, BlinkMacSystemFont, "Noto Sans TC",
    "Microsoft JhengHei", sans-serif;
  --text-base: 1.0625rem;  /* 17px */
  --text-small: 0.9375rem;
  --text-title: 1.1875rem;
  --text-h1: clamp(1.5rem, 1.2rem + 1.4vw, 2.125rem);

  --gutter: 16px;
  --radius: 12px;
  --radius-small: 8px;
  --tap: 48px;
  --shadow-card: 0 1px 2px rgb(29 36 48 / 0.06), 0 4px 14px rgb(29 36 48 / 0.07);
  --shadow-lift: 0 2px 4px rgb(29 36 48 / 0.08), 0 14px 36px rgb(29 36 48 / 0.16);
  --focus: 3px solid var(--indigo);
  --duration: 160ms;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

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

a { color: var(--indigo); }

:focus-visible {
  outline: var(--focus);
  outline-offset: 3px;
}

/* ---------- 頁首 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--indigo);
  color: #fff;
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1400px;
  min-height: 56px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.brand {
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.crumb {
  display: none;
  min-width: 0;
  color: rgb(255 255 255 / 0.75);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .crumb { display: block; }
}

.crumb::before { content: "／"; margin-right: 8px; color: rgb(255 255 255 / 0.4); }

.logout { margin: 0 0 0 auto; }

.banner {
  margin: 0;
  padding: 12px var(--gutter);
  background: var(--shu-tint);
  color: var(--shu-ink);
  border-bottom: 2px solid var(--shu);
  text-align: center;
  font-size: var(--text-small);
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px var(--gutter) 64px;
}

.page-title {
  margin: 4px 0 12px;
  color: var(--indigo);
  font-size: var(--text-h1);
  line-height: 1.25;
}

/* ---------- 摘要 ---------- */

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 24px;
}

.summary-item {
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 500;
}

.summary-pending {
  background: var(--shu-tint);
  color: var(--shu-ink);
  box-shadow: inset 0 0 0 1px var(--shu);
}

.summary-ok { color: var(--ok); }

/* ---------- 格子 ---------- */

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
}

.card {
  position: relative;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  scroll-margin-top: 72px;
  transition: box-shadow var(--duration) ease, transform var(--duration) ease;
}

.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }

.card--warn::before {  /* 朱色左邊框：疊在照片之上，整格高度 */
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  width: 5px;
  background: var(--shu);
  pointer-events: none;
}

.scene-hit {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.scene-hit:focus-visible { outline-offset: -3px; border-radius: var(--radius); }

.scene-photo {
  display: block;
  aspect-ratio: 16 / 9;
  background: var(--paper-deep);
}

.scene-photo img { width: 100%; height: 100%; object-fit: cover; }

.photo-missing,
.preview-missing {
  display: grid;
  place-items: center;
  height: 100%;
  margin: 0;
  color: var(--shu-ink);
  font-weight: 500;
  background:
    repeating-linear-gradient(135deg, transparent 0 12px, rgb(224 122 98 / 0.08) 12px 24px),
    var(--paper-deep);
}

.scene-body {
  display: grid;
  gap: 4px;
  padding: 14px 18px 16px;
}

.card--warn .scene-body { padding-left: 22px; }

.scene-id {
  margin: 0;
  color: var(--ink-faint);
  font-size: var(--text-small);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.scene-title {
  color: var(--indigo);
  font-size: var(--text-title);
  font-weight: 600;
  line-height: 1.4;
}

.scene-narr { color: var(--ink-soft); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.tag {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--shu-tint);
  color: var(--shu-ink);
  font-size: var(--text-small);
  font-weight: 600;
}

.scene-cta {
  margin-top: 6px;
  color: var(--indigo);
  font-size: var(--text-small);
  font-weight: 500;
}

.scene-cta::after { content: " ›"; }

/* ---------- 展開的編輯區 ---------- */

.editor {
  grid-column: 1 / -1;
  padding: 20px var(--gutter) 24px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lift), inset 0 4px 0 var(--indigo);
  scroll-margin-top: 72px;
}

.editor-head h2 {
  margin: 0 0 12px;
  color: var(--indigo);
  font-size: 1.375rem;
  line-height: 1.35;
}

.editor-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}

@media (min-width: 900px) {
  .editor { padding: 28px 32px 32px; }
  .editor-form { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 32px; }
}

.preview {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-small);
  overflow: hidden;
  background: var(--indigo-deep);
}

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

.wrap-box {
  position: absolute;
  border: 2px dashed var(--wrap-yellow);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35);
  pointer-events: none;
}

.hint { margin: 8px 0 0; color: var(--ink-soft); font-size: var(--text-small); }
.hint-warn { color: var(--shu-ink); font-weight: 500; }

.photos {
  min-width: 0;
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}

.photos legend {
  padding: 0;
  margin-bottom: 8px;
  font-weight: 600;
}

.legend-note {
  margin-left: 6px;
  color: var(--ink-faint);
  font-size: var(--text-small);
  font-weight: 400;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.photo-pick {
  display: block;
  aspect-ratio: 16 / 9;
  min-height: var(--tap);
  padding: 0;
  border: 0;
  border-radius: var(--radius-small);
  overflow: hidden;
  background: var(--paper-deep);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line);
}

.photo-pick img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick:hover img { opacity: 0.85; }

.photo-pick.is-current {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--indigo);
}

.more-photos { margin-top: 12px; }

.more-photos summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  margin-bottom: 8px;
  color: var(--indigo);
  font-weight: 500;
  cursor: pointer;
}

.editor-text { display: grid; gap: 16px; align-content: start; }

.field { display: grid; gap: 6px; }

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
}

.estimate { color: var(--ink-faint); font-weight: 400; font-size: var(--text-small); }

input[type="text"],
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
}

textarea { resize: vertical; }
textarea[rows="2"] { min-height: 4.25em; }

input[type="text"]:focus-visible,
textarea:focus-visible {
  outline: var(--focus);
  outline-offset: 0;
  border-color: var(--indigo);
  background: var(--surface);
}

.is-wrapped { border-color: var(--shu); background: var(--shu-tint); }

.field-warn { color: var(--shu-ink); font-size: var(--text-small); font-weight: 500; }

.alert,
.saved {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: var(--radius-small);
  font-weight: 500;
}

.alert { background: var(--shu-tint); color: var(--shu-ink); border-left: 5px solid var(--shu); }
.saved { background: #e9f2ec; color: var(--ok); }

/* ---------- 按鈕 ---------- */

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions-later { padding-top: 12px; border-top: 1px solid var(--line); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 20px;
  border: 1.5px solid var(--indigo);
  border-radius: 999px;
  background: var(--surface);
  color: var(--indigo);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--duration) ease, transform var(--duration) ease;
}

.btn:hover { background: var(--indigo-tint); }
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-deep); }

.btn-quiet { border-color: transparent; }

.btn-quiet-dark {
  min-height: 44px;
  border-color: rgb(255 255 255 / 0.5);
  background: transparent;
  color: #fff;
}

.btn-quiet-dark:hover { background: rgb(255 255 255 / 0.12); }
.btn-quiet-dark:focus-visible { outline-color: #fff; }

.btn-small { min-height: 44px; padding: 0 14px; font-size: var(--text-small); }

.btn:disabled {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink-faint);
  cursor: not-allowed;
  transform: none;
}

.htmx-request .btn, .btn.htmx-request { opacity: 0.7; }

/* ---------- 登入、訊息、專案列表 ---------- */

.notice {
  max-width: 32rem;
  margin: 8vh auto 0;
  padding: 28px 24px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.notice h1 { margin: 0 0 8px; color: var(--indigo); font-size: 1.5rem; }

.project-list { display: grid; gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
.project-list .btn { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
  .card:hover { transform: none; }
}

/* ---------- 送出失敗提示（studio.js） ---------- */

.net-error {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  margin: 0;
  padding: 12px var(--gutter);
  background: var(--shu-ink);
  color: #fff;
  box-shadow: var(--shadow-lift);
}

.net-error[hidden] { display: none; }

.net-error-text { margin: 0; font-weight: 600; }

.net-error .btn { border-color: #fff; }

/* ---------- 工作狀態與成片列表 ---------- */

.job-details { margin: -8px 0 12px; font-size: var(--text-small); color: var(--ink-soft); }
.job-details summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; }
.job-details pre {
  margin: 0;
  padding: 12px;
  max-height: 16rem;
  overflow: auto;
  border-radius: var(--radius-small);
  background: var(--paper-deep);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.renders { margin: 8px 0 24px; }

.renders-title { margin: 0 0 8px; color: var(--indigo); font-size: var(--text-title); }

.renders-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }

.renders-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.renders-label { font-variant-numeric: tabular-nums; }
