/* 視覺編輯 + 圖片三種顯示模式（crop / scale / pan）。正式站也載入，訪客才能看到已選的裁切／縮放／拖動範圍。 */

.cms-slot {
  position: relative;
  display: block;
  overflow: hidden;
  width: 100%;
  min-height: 1px;
}

.cms-slot > img,
.cms-slot > video {
  display: block;
}

.cms-slot[data-fit="crop"] > img,
.cms-slot[data-fit="crop"] > video {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover !important;
  object-position: var(--cms-x, 50%) var(--cms-y, 50%) !important;
}

.cms-slot[data-fit="scale"] > img,
.cms-slot[data-fit="scale"] > video {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
  object-position: var(--cms-x, 50%) var(--cms-y, 50%) !important;
}

.cms-slot[data-fit="pan"] > img,
.cms-slot[data-fit="pan"] > video {
  position: absolute;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: unset !important;
  object-position: unset !important;
}

body.cms-editing {
  padding-top: 96px;
}

.cms-bar-pages {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  margin-top: 2px;
  border-top: 1px solid #333;
}

.cms-bar-pages a {
  background: #222 !important;
  padding: 0.32rem 0.7rem !important;
}

.cms-bar-pages a.is-current,
.cms-bar-pages a[aria-current="page"] {
  background: #ed1c24 !important;
}

.cms-bar-lang {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.cms-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  padding: 0.55rem 0.9rem;
  background: #111;
  color: #fff;
  font-family: "Noto Sans TC", Bahnschrift, Arial, sans-serif;
  font-size: 13px;
}

.cms-bar.is-dirty .cms-bar-mark::after {
  content: " · 未存正式版";
  color: #f5c542;
}

.cms-bar-mark {
  letter-spacing: 0.12em;
  font-size: 11px;
  color: #ed1c24;
}

.cms-bar-hint {
  color: #bbb;
}

.cms-bar input,
.cms-bar select,
.cms-bar button,
.cms-bar a {
  font: inherit;
  color: #fff;
}

.cms-bar input,
.cms-bar select {
  background: #222;
  border: 1px solid #444;
  padding: 0.28rem 0.45rem;
  min-width: 11rem;
}

.cms-bar button,
.cms-bar a {
  background: #333;
  border: 0;
  padding: 0.32rem 0.65rem;
  text-decoration: none;
  cursor: pointer;
}

.cms-bar .cms-primary {
  background: #ed1c24;
}

.cms-t {
  outline: 1px dashed transparent;
  min-width: 0.8em;
}

body.cms-editing .cms-t:hover,
body.cms-editing .cms-slot:hover {
  outline: 2px dashed #ed1c24;
}

.cms-t:focus {
  outline: 2px solid #ed1c24;
  background: rgba(237, 28, 36, 0.08);
}

.cms-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.cms-replace,
.cms-clear {
  position: absolute;
  top: 10px;
  z-index: 30;
  border: 0;
  color: #fff;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 6px 10px;
  cursor: pointer;
}

.cms-replace {
  right: 10px;
  background: #ed1c24;
}

.cms-clear {
  left: 10px;
  background: #fff;
  color: #111;
}

.cms-slot.is-empty {
  min-height: 180px;
  background: #173b4d;
}

.cms-card-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}

.cms-card-bar button {
  position: static !important;
  min-height: 40px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #ed1c24;
  background: #fff;
  color: #ed1c24;
}

.cms-card-bar [data-cms-replace] {
  background: #ed1c24;
  color: #fff;
}

.cms-card-bar .cms-list-remove {
  background: #111;
  border-color: #111;
  color: #fff;
}

body.cms-editing .cms-slot {
  cursor: grab;
}

body.cms-editing .cms-slot.is-dragging,
body.cms-editing .cms-slot.cms-slot-active {
  cursor: grabbing;
  outline: 2px solid #ed1c24;
}

.cms-fit-panel {
  position: fixed;
  z-index: 4100;
  width: min(280px, calc(100vw - 24px));
  background: #111;
  color: #fff;
  padding: 12px 14px;
  font-family: "Noto Sans TC", Bahnschrift, Arial, sans-serif;
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.cms-fit-title {
  margin: 0 0 10px;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: #ed1c24;
}

.cms-fit-modes {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.cms-fit-modes button {
  font: inherit;
  color: #fff;
  background: #222;
  border: 1px solid #444;
  padding: 8px 4px;
  cursor: pointer;
}

.cms-fit-modes button[aria-pressed="true"] {
  background: #ed1c24;
  border-color: #ed1c24;
}

.cms-fit-hint {
  margin: 10px 0 12px;
  color: #bbb;
  font-size: 12px;
  line-height: 1.55;
}

.cms-fit-replace {
  width: 100%;
  font: inherit;
  color: #fff;
  background: #333;
  border: 0;
  padding: 8px 10px;
  cursor: pointer;
}

.cms-fit-clear {
  margin-top: 8px;
  background: #444;
}

.cms-list-add,
.cms-list-remove {
  font: inherit;
  cursor: pointer;
}

.cms-list-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 18px;
  margin: 16px 0 8px;
  border: 1px dashed #ed1c24;
  background: transparent;
  color: #ed1c24;
  font-weight: 600;
}

.cms-list-remove {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 31;
  border: 0;
  background: #111;
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
}

.cms-list-remove.is-inline {
  position: static;
  display: inline-flex;
  margin: 0 0 12px;
}

.cms-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  margin: 12px 0;
}

.cms-field select,
.cms-field input {
  font: inherit;
  min-height: 40px;
  padding: 6px 8px;
}

@media (prefers-reduced-motion: reduce) {
  .cms-slot > img,
  .cms-slot > video {
    transition: none;
  }
}
