/* 自動補樣式：js/screens/side-effects.js（_build/style.py） */
/* ==========================================================================
   身體感受頁 side-effects.js
   對應 class：c-dots、c-input、s-se-*
   顏色、圓角、間距一律使用 tokens.css 變數
   ========================================================================== */

/* ---------- c-input（文字框與多行文字） ---------- */
.c-input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 var(--sp-4);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--r-input);
  font: inherit;
  font-size: max(16px, 1rem);
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}

textarea.c-input {
  min-height: 96px;
  padding: var(--sp-3) var(--sp-4);
  resize: vertical;
}

.c-input::placeholder {
  color: var(--text-3);
}

.c-input:focus,
.c-input:focus-visible {
  border-color: var(--primary);
  background: var(--surface);
}

@media (pointer: fine) {
  .c-input {
    min-height: 44px;
  }
  textarea.c-input {
    min-height: 96px;
  }
}

/* ---------- c-dots（程度小點，裝飾用） ---------- */
.c-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: var(--sp-1);
  flex: none;
}

.c-dots__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border);
}

.c-dots__dot.is-on {
  background: var(--primary);
  box-shadow: none;
}

/* ---------- 版面骨架 ---------- */
.s-se {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
}

.s-se--form {
  width: 100%;
  margin-inline: auto;
  max-width: var(--content-max-form, 720px);
}

.s-se-master,
.s-se-detail,
.s-se-extras,
.s-se-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
}

.s-se-list {
  gap: var(--sp-2);
}

.s-se-detail {
  container-type: inline-size;
  container-name: view;
}

/* ---------- 頂部：說明與動作 ---------- */
.s-se-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.s-se-caption {
  flex: 1 1 220px;
  min-width: 0;
  margin: 0;
  font-size: var(--fs-callout);
  line-height: 1.5;
  color: var(--text-2);
}

.s-se-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: none;
  margin-left: auto;
}

/* ---------- 標題與說明文字 ---------- */
.s-se-title {
  margin: 0;
  font-size: var(--fs-title2);
  line-height: 1.27;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

.s-se-h {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-title3);
  line-height: 1.33;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.s-se-note {
  margin: var(--sp-2) 0 0;
  font-size: var(--fs-footnote);
  line-height: 1.5;
  color: var(--text-3);
}

/* ---------- 清單 ---------- */
.s-se-month {
  margin: var(--sp-4) 0 var(--sp-1);
  padding: 0 var(--sp-1);
  font-size: var(--fs-footnote);
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-3);
}

.s-se-list > .s-se-month:first-child {
  margin-top: 0;
}

.s-se-list > a {
  text-decoration: none;
  transition: background var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}

.s-se-list > a.is-selected {
  background: var(--primary-tint);
  box-shadow: inset 3px 0 0 var(--primary);
}

.s-se-list > a:focus-visible {
  outline-offset: 2px;
}

.s-se-row__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-1) var(--sp-3);
  margin-bottom: var(--sp-2);
}

.s-se-daytag {
  max-width: 100%;
  white-space: normal;
  font-variant-numeric: tabular-nums;
}

.s-se-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.s-se-chips .s-se-chip,
.s-se-chip {
  min-height: 32px;
  padding: 0 var(--sp-3);
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--text);
  font-size: var(--fs-footnote);
  font-weight: 500;
  cursor: default;
}

.s-se-none {
  margin: 0;
  font-size: var(--fs-footnote);
  line-height: 1.4;
  color: var(--text-3);
}

.s-se-row__flag {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  margin: var(--sp-3) 0 0;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  color: var(--text);
  font-size: var(--fs-footnote);
  line-height: 1.45;
}

.s-se-row__flag svg {
  flex: none;
  margin-top: 1px;
  color: var(--danger);
}

/* ---------- 記錄摘要 ---------- */
.s-se-summary {
  min-width: 0;
}

.s-se-summary .s-se-sumlist {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.s-se-sum__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-1) var(--sp-3);
  padding: var(--sp-2) 0;
  font-variant-numeric: tabular-nums;
}

.s-se-sum__row + .s-se-sum__row {
  border-top: 1px solid var(--divider);
}

.s-se-sum__label {
  min-width: 4.5em;
  font-size: var(--fs-body);
  line-height: 1.4;
  font-weight: 600;
  color: var(--text);
}

.s-se-sum__meta {
  font-size: var(--fs-footnote);
  line-height: 1.4;
  color: var(--text-2);
}

/* ---------- 看規律（選填）：details ---------- */
.s-se-heatwrap {
  padding: 0 var(--sp-5);
}

.s-se-heatsum {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 56px;
  font-size: var(--fs-title3);
  line-height: 1.33;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  list-style: none;
  cursor: pointer;
  border-radius: var(--r-sm);
}

.s-se-heatsum::-webkit-details-marker {
  display: none;
}

.s-se-heatsum::marker {
  content: '';
}

.s-se-heatsum::after {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 2px solid var(--text-3);
  border-bottom: 2px solid var(--text-3);
  transform: rotate(45deg);
  transition: transform var(--dur-2) var(--ease);
}

.s-se-heatwrap[open] > .s-se-heatsum::after {
  transform: rotate(-135deg);
}

.s-se-heatsum:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.s-se-heatwrap > :not(summary) {
  min-width: 0;
}

.s-se-heatwrap[open] {
  padding-bottom: var(--sp-5);
}

.s-se-heatwrap[open] > .s-se-heatsum {
  margin-bottom: var(--sp-2);
}

.s-se-readout {
  min-height: 44px;
  margin: var(--sp-3) 0 0;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-input);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-callout);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.s-se-insight {
  margin: var(--sp-3) 0 0;
  padding: var(--sp-3) var(--sp-4);
  border-left: 3px solid var(--primary);
  border-radius: var(--r-sm);
  background: var(--primary-tint);
  color: var(--text);
  font-size: var(--fs-callout);
  line-height: 1.55;
}

/* ---------- 表單 ---------- */
.s-se-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: 100%;
  max-width: var(--content-max-form, 720px);
  min-width: 0;
}

.s-se-timecard,
.s-se-symcard,
.s-se-flagcard {
  min-width: 0;
}

.s-se-symptoms {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.s-se-symcard .c-field {
  margin-top: var(--sp-4);
}

.s-se-flag {
  min-width: 0;
}

.s-se-flag:not(:empty) {
  margin-top: var(--sp-3);
}

.s-se-helprow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.s-se-flagcard .c-check-list {
  margin-top: var(--sp-1);
}

.s-se-formactions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
}

.s-se-formactions > .c-btn--primary {
  flex: 1 1 200px;
}

.s-se-formactions > .c-btn--ghost {
  flex: 0 1 auto;
  min-width: 96px;
}

/* ---------- 平板：md ---------- */
@media (min-width: 600px) {
  .s-se-form {
    gap: var(--sp-4);
  }
  .s-se-head {
    gap: var(--sp-4);
  }
}

/* ---------- 容器查詢：較寬的欄 ---------- */
@container view (min-width: 640px) {
  .s-se-sum__row {
    gap: var(--sp-1) var(--sp-4);
  }
  .s-se-formactions > .c-btn--primary {
    flex: 0 1 280px;
  }
}

/* ---------- 桌面：master-detail（lg） ---------- */
@media (min-width: 1024px) and (min-height: 501px), (min-width: 1024px) and (orientation: portrait) {
  .s-se-master {
    container-type: inline-size;
    container-name: view;
    position: sticky;
    top: var(--topbar-total);
    max-height: calc(100dvh - var(--topbar-total));
    overflow: auto;
    overscroll-behavior: contain;
    padding: 4px;
    margin: -4px;
  }
  .s-se-detail {
    gap: var(--sp-4);
  }
  .s-se-detail .s-se-form {
    max-width: var(--content-max-form, 720px);
  }
  .s-se-detail .s-se-extras {
    max-width: var(--content-max-form, 720px);
  }
  .s-se-detail > .s-se-extras {
    gap: var(--sp-4);
  }
}

/* ---------- 手機橫式與矮螢幕：表單兩欄 ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  .s-se--form {
    max-width: none;
  }
  .s-se-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-3);
    max-width: none;
    align-items: start;
  }
  .s-se-form > .s-se-title,
  .s-se-form > .s-se-caption,
  .s-se-form > .s-se-symcard,
  .s-se-form > .s-se-formactions,
  .s-se-form > .c-btn--danger {
    grid-column: 1 / -1;
  }
  .s-se-symptoms {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--sp-6);
  }
  .s-se-master {
    max-height: none;
  }
  .s-se-heatsum {
    min-height: 48px;
  }
}

/* ---------- 滑鼠 hover ---------- */
@media (hover: hover) and (pointer: fine) {
  .s-se-list > a:hover {
    background: var(--surface-3);
  }
  .s-se-list > a.is-selected:hover {
    background: var(--primary-tint);
  }
  .s-se-heatsum:hover {
    color: var(--primary);
  }
  .s-se-heatsum:hover::after {
    border-color: var(--primary);
  }
  .c-input:hover:not(:focus) {
    border-color: var(--border);
  }
}

/* ---------- 減少動態 ---------- */
@media (prefers-reduced-motion: reduce) {
  .c-input,
  .s-se-list > a,
  .s-se-heatsum::after {
    transition-duration: 0.01ms !important;
  }
}
