@import url("./cycle-theme.css");

/* Story and doom dialogs live outside .app and need the same control styles. */
.card-track-dialog,
.card-track-item,
.card-track-face,
.card-track-empty,
.card-track-knowledge,
.card-track-progress-badge,
.card-track-side-badge,
.card-track-preview-badge,
.card-track-dialog :is(button, input, select, textarea) { border-radius: 0; }
.card-track-dialog, .card-track-face { box-shadow: none; }
.card-track-dialog, .card-track-item { background: var(--panel); }
.card-track-item { border-color: var(--line); }
.card-track-head h2 {
  font-family: "Songti SC", "Noto Serif CJK SC", SimSun, Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--accent-strong);
}
.card-track-title { color: var(--accent-strong); font-weight: 600; }
.card-track-status, .card-track-counter-label, .card-track-knowledge-label,
.card-track-meta, .card-track-dialog button { font-weight: 600; }
.card-track-face, .card-track-empty { border-color: var(--line); background: var(--bg); }
.card-track-knowledge { border-color: var(--line); background: var(--accent-soft); }
.card-track-knowledge-value { font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
.card-track-side-badge { border-color: var(--line); background: var(--panel); color: var(--accent-strong); font-weight: 600; }
.card-track-progress-badge, .card-track-preview-badge { border-color: var(--accent-strong); background: var(--accent-strong); color: #fff; font-weight: 600; }
.card-track-dialog :is(input, select, textarea) { border-color: var(--line); background: var(--panel); color: var(--ink); font-weight: 500; }
.card-track-close, .card-track-progress button, .card-track-counter button, .card-track-retreat {
  border-color: var(--line);
  background: var(--panel);
  color: var(--accent-strong);
}
.card-track-close:hover, .card-track-progress button:hover, .card-track-counter button:hover, .card-track-retreat:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.card-track-advance { border-color: var(--accent-strong); background: var(--accent-strong); color: #fff; }
.card-track-advance:hover { border-color: var(--accent); background: var(--accent); }
.card-track-dialog :is(button, input, select, textarea):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

body {
  background: var(--bg);
  line-height: 1.6;
}

/* The darker accent keeps white button text legible in the gold cycle too. */
button {
  background: var(--accent-strong);
}

:is(button, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.app {
  padding: 40px clamp(20px, 4vw, 56px) 32px;
}

.app button,
.app a.secondary {
  border-radius: 0;
  font-weight: 600;
  transition: background-color 140ms ease, color 140ms ease;
}

/* 「战役简报」是链接，但要和前几个按钮长得完全一样：这里补齐按钮的基础几何
   （基础 button 规则在 index.html 的内联样式里，链接拿不到）。 */
.app a.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  text-decoration: none;
  cursor: pointer;
}

.app button.secondary,
.app a.secondary {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent);
}

.app button.secondary:hover,
.app a.secondary:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.app :is(input:not([type="checkbox"]):not([type="range"]):not([type="file"]), textarea, select) {
  min-width: 0;
  border-radius: 0;
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 500;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 28px;
  margin-bottom: 28px;
}

.cycle-title {
  color: var(--accent-strong);
  font-family: "Songti SC", "Noto Serif CJK SC", SimSun, Georgia, serif;
  font-size: clamp(30px, 3.4vw, 44px);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: .04em;
}

.cycle-title .cycle-symbol {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
}

.campaign-save-status {
  align-items: center;
  gap: 7px;
  font-weight: 500;
}

.campaign-save-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.day-card {
  width: auto;
  min-width: 0;
  grid-template-columns: 72px auto;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 14px;
  background: var(--panel);
  box-shadow: none;
}

.day-card label {
  gap: 0;
  font-size: 12px;
  font-weight: 500;
}

.day-card #dayInput {
  width: 72px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 0 0 2px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 36px;
  font-weight: 400;
  text-align: center;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.day-actions {
  grid-column: 2;
  grid-template-columns: repeat(2, max-content);
  align-content: center;
  align-items: center;
  gap: 8px;
}

.archive-actions {
  display: grid;
  /* 导出和导入略宽，战役简报略窄；整行与上方账号操作行同宽。 */
  grid-template-columns: 1.1fr 1.1fr 0.8fr;
  align-items: center;
  gap: 6px;
}

.app .archive-actions :is(button, a) {
  min-width: 0;
  padding-inline: 8px;
  white-space: nowrap;
}

.app .archive-actions :is(button, a) { width: 100%; }

.dashboard-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  border-block: 1px solid var(--line);
  margin-bottom: 36px;
  padding-block: 10px;
}

.record-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 30px;
}

.record-links .campaign-save-status {
  max-width: 100%;
  white-space: normal;
}

.app .record-card-link {
  min-height: 40px;
  justify-content: flex-start;
  border: 0;
  border-radius: 0;
  padding: 6px 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.record-card-link::after {
  content: "↗";
  margin-left: 8px;
  color: var(--gold);
}

/* 跳转行图标：字形是 assets/icons/<名称>.svg，由 .atopack 的 iconFiles 段随包安装
   （程序包不带这些提取自原 App 的素材，见 tools/packaging/package_common.py）。
   这里用 CSS 遮罩 + currentColor 上色，图标照旧跟随链接颜色与悬停色；没有字形时
   这一格自然为空，文字标签不受影响。
   每个字形按「等包围盒面积」缩放，尺寸由内联的 --nav-icon-w/h 给出，
   否则扁长的字形（如 argo 120x81）会比近方形的字形明显偏小。 */
.app .record-card-link > .nav-icon {
  width: var(--nav-icon-w, 16px);
  height: var(--nav-icon-h, 16px);
  flex: 0 0 auto;
  margin-right: 6px;
  background-color: currentColor;
  -webkit-mask-image: var(--icon-src);
  mask-image: var(--icon-src);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.app .record-card-link:hover {
  background: transparent;
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 5px;
}

.title-cycle-control {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
}

.title-cycle-control select {
  min-width: 180px;
  min-height: 40px;
}

.grid {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 16px;
}

.grid > .stack {
  gap: 16px;
}

.app .panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 16px;
  background: var(--panel);
  box-shadow: none;
  overflow: visible;
}

.panel-head {
  min-height: 48px;
  padding: 0 0 14px;
  background: transparent;
  align-items: baseline;
}

.panel-head h2 {
  font-family: "Songti SC", "Noto Serif CJK SC", SimSun, Georgia, serif;
  color: var(--accent-strong);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: .05em;
}

.panel-body {
  padding: 16px 0 0;
}

.flow-head-tools {
  min-width: 0;
}

.progress {
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.progress-track {
  width: 100px;
  height: 3px;
  border-radius: 0;
  background: var(--line);
}

.flow-list {
  gap: 0;
}

.flow-step {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 24px 0;
  gap: 14px;
  background: transparent;
}

.flow-step:first-child {
  padding-top: 8px;
}

.flow-step.done {
  border-color: var(--line);
  background: transparent;
}

.flow-step.done .step-desc {
  color: #667867;
}

.flow-check {
  appearance: none;
  width: 20px;
  height: 20px;
  margin: 5px 0 0;
  padding: 4px;
  border: 1px solid var(--accent);
  border-radius: 0;
  background: transparent;
  background-clip: content-box;
}

.flow-check:checked {
  background-color: var(--accent);
}

.flow-check:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.step-title {
  gap: 8px 12px;
  margin-bottom: 8px;
  font-size: 17px;
  font-weight: 600;
}

.step-index {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  font-weight: 400;
}

.step-kind {
  font-size: 11px;
  font-weight: 500;
}

.step-desc {
  line-height: 1.8;
}

.step-actions {
  gap: 6px 10px;
}

.step-actions a {
  border: 0;
  border-radius: 0;
  padding-inline: 4px;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 5px;
  font-weight: 600;
}

.step-actions a:hover {
  background: var(--accent-soft);
}

.app :is(.step-track-reminder, .exploration-tools, .exploration-removed-pile,
  .exploration-hidden, .exploration-destruction, .exploration-builder,
  .exploration-faction-chip, .exploration-destruction-card, .survey-constants,
  .survey-constant-card, .survey-hub-summary, .event-item, .second-screen-card,
  .empty, .field-note, .session-account) {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.app :is(.exploration-tools, .exploration-hidden, .exploration-destruction) {
  border-top: 1px solid var(--line);
  padding: 10px 0 0;
}

.app .survey-constants {
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  padding: 0;
}

.survey-constants summary {
  padding: 9px 10px;
  color: var(--accent-strong);
  font-weight: 600;
}

.survey-constants[open] > summary {
  border-bottom: 1px solid var(--line);
}

.survey-constants-body {
  padding: 10px;
  background: var(--bg);
}

.survey-constant-heading {
  color: var(--accent-strong);
}

.survey-constants-body > .survey-constant-group + .survey-constant-group {
  border-top: 1px solid var(--accent);
  margin-top: 8px;
  padding-top: 18px;
}

.survey-hub-summary-row {
  border-color: var(--line);
}

.survey-hub-summary-row.header,
.survey-hub-summary-row.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.app .survey-constant-tag {
  border-radius: 0;
}

.survey-constant-card {
  padding: 8px 0;
}

.app .step-track-reminder {
  border-left: 2px solid var(--gold);
  padding: 8px 12px;
}

.app .step-track-reminder.important {
  border-left: 2px solid var(--danger);
  background: #f6ebe3;
}

.app .step-track-reminder.tech {
  border-left: 2px solid var(--accent);
}

.app .step-track-reminder.terrain {
  background: var(--accent-soft);
}

.app .step-track-reminder.calamity {
  border-left: 4px solid #a52206;
  background: #f8ded8;
}

.app .step-track-reminder.story-progress {
  border-left: 4px solid #216849;
  background: #dcefe3;
}

.app .step-track-reminder.calamity .step-track-tag {
  background: #a52206;
  color: #fff;
}

.app .step-track-reminder:is(.terrain, .calamity, .story-progress) .step-track-desc {
  color: var(--ink);
}

.app .step-track-reminder.battle-tech {
  border: 1px solid #a8b9dc;
  border-left: 4px solid #355a9a;
  background: #e0e9fa;
}

.app .step-track-reminder.structure-tech {
  border: 1px solid #98c5b2;
  border-left: 4px solid #216849;
  background: #dcefe3;
}

.app .step-track-reminder:is(.battle-tech, .structure-tech) .step-track-desc {
  color: var(--ink);
}

.app :is(.date-track-icon, .step-track-tag).battle-tech {
  background: #355a9a;
  color: #fff;
}

.app :is(.date-track-icon, .step-track-tag).structure-tech {
  background: #216849;
  color: #fff;
}

.date-track-list {
  max-height: 420px;
  gap: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.date-track-item {
  min-height: 44px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 8px 10px;
  background: transparent;
  font-weight: 500;
}

.date-track-item:is(.event, .noted) {
  border-color: var(--line);
  background: transparent;
}

/* C4 可以一直往后推，没有上限。时间表之外的续推日用虚线隔开，表示它不是印刷
   时间表里的一行（见 index.html 的 trackEntriesForRender）。 */
.date-track-item.beyond-track {
  border-top: 1px dashed var(--line);
}

.date-track-item:hover {
  background: var(--accent-soft);
}

.date-track-item.current,
.date-track-item.current.noted {
  border: 0;
  border-left: 3px solid var(--accent);
  border-bottom: 1px solid var(--line);
  padding-left: 7px;
  background: var(--accent-soft);
  box-shadow: none;
}

.date-track-day {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-size: 18px;
}

.date-track-icon {
  border-radius: 0;
  font-weight: 600;
}

.date-track-meta {
  font-size: 12px;
  font-weight: 500;
}

.app .second-screen-card {
  border-top: 1px solid var(--line);
  padding: 14px 0 0;
}

.app .exploration-builder {
  border-top: 1px solid var(--line);
}

.exploration-builder summary {
  padding: 10px 0;
  font-weight: 600;
}

.exploration-builder-body {
  padding-inline: 0;
}

.app .exploration-library label {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 0;
  background: transparent;
}

.app .exploration-faction-chip {
  padding: 2px 0;
}

.app .exploration-destruction-card {
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}

.session-account {
  padding: 0;
}

.app #notesInput {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 12px;
  background: var(--bg);
  line-height: 1.8;
}

.app #notesInput::placeholder {
  color: #777b70;
}

.app .ato-bgm-bar :is(button, select, .ato-bgm-import) {
  border-radius: 0;
}

.app :is(.exploration-drawn-face, .exploration-library-preview,
  .negotiation-card-back, .titan-x-step-track,
  .titan-x-step-track [data-titan-x-space], .dashboard-writer-notice) {
  border-radius: 0;
}

.app .app-updates {
  margin-top: 40px;
  padding-top: 20px;
  font-size: 12px;
}

.app .app-updates a {
  color: var(--accent);
}

.app .update-notice {
  border-radius: 0;
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

.app .update-status.update-error {
  color: var(--danger);
}

.auth-panel {
  border: 0;
  border-top: 3px solid var(--accent);
  border-radius: 0;
  padding: 32px;
}

.auth-panel h1 {
  color: var(--accent-strong);
  font-family: "Songti SC", SimSun, Georgia, serif;
  font-weight: 600;
  line-height: 1.4;
}

@media (max-width: 1040px) {
  .grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .grid > .stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 28px 0 0;
  }

  .date-track-list {
    max-height: 300px;
  }

  .flow-head-tools {
    width: auto;
  }
}

@media (max-width: 780px) {
  .app {
    padding-top: 28px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 20px;
  }

  .day-card {
    width: 100%;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
    padding: 12px 14px;
  }

  .day-card #dayInput {
    width: 72px;
    font-size: 40px;
  }

  .day-actions {
    grid-template-columns: auto auto;
    justify-content: end;
    align-content: center;
    align-items: center;
  }

  .day-actions button {
    font-size: 12px;
    padding-inline: 10px;
  }

  .dashboard-navigation {
    margin-bottom: 28px;
  }
}

@media (max-width: 620px) {
  .cycle-title {
    font-size: clamp(24px, 6vw, 32px);
    gap: 10px;
  }

  .cycle-title .cycle-symbol {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .app .panel {
    padding: 16px;
  }

  .app .survey-constant-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .grid > .stack {
    grid-template-columns: minmax(0, 1fr);
  }

  .record-links {
    gap: 4px 20px;
  }

  .app .record-links .record-card-link {
    font-size: 12px;
    padding-inline: 0;
  }

  .app .record-links .record-card-link > .nav-icon {
    /* 14/16，随窄屏字号一起收一点 */
    width: calc(var(--nav-icon-w, 16px) * 0.875);
    height: calc(var(--nav-icon-h, 16px) * 0.875);
    margin-right: 4px;
  }

  .dashboard-navigation .title-cycle-control {
    width: 100%;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    padding-top: 10px;
  }

  .title-cycle-control select {
    flex: 1;
    max-width: 260px;
  }

  .panel-head {
    flex-direction: row;
    align-items: baseline;
    flex-wrap: wrap;
  }

  .flow-head-tools {
    max-width: 100%;
  }

  .progress-track {
    width: 72px;
  }

  .flow-step {
    gap: 10px;
    padding-block: 20px;
  }

  .step-actions {
    width: 100%;
    margin-top: 4px;
  }

  .app .step-action-button,
  .step-actions a {
    min-height: 36px;
  }

  .step-title {
    font-size: 16px;
  }

  .second-screen-scale {
    grid-template-columns: auto minmax(0, 1fr) 44px;
  }

  .second-screen-scale.with-rotation {
    grid-template-columns: auto minmax(0, 1fr) 44px auto auto;
  }

  .app-credit {
    text-align: left;
  }
}

@media (max-width: 360px) {
  .day-card {
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 8px;
  }

  .day-card #dayInput {
    width: 60px;
    font-size: 36px;
  }

  .day-actions button {
    font-size: 11px;
    padding-inline: 8px;
    white-space: nowrap;
  }

  .app .archive-actions button {
    padding-inline: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app button,
  .progress-fill {
    transition: none;
  }
}
