/* 年终奖计算器的页面样式。配色变量来自 /shared/base.css，深色模式跟着系统走。 */

/* 下面几处用 display 布局的元素靠 hidden 属性收起，要压过 display */
[hidden] {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-bg) 92%, transparent);
  backdrop-filter: blur(8px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--tap-min);
}

.topbar-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.topbar-home {
  display: grid;
  place-items: center;
  width: var(--tap-min);
  height: var(--tap-min);
  margin-right: -10px;
  border-radius: 50%;
  color: var(--color-text-muted);
}

.topbar-home:hover {
  background: color-mix(in srgb, var(--color-text) 8%, transparent);
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-block: 16px 48px;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.card {
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.card h3 {
  margin: 16px 0 8px;
  font-size: 15px;
}

.card h3:first-child {
  margin-top: 0;
}

/* 结果卡片 */

.result {
  border-color: color-mix(in srgb, var(--color-accent) 40%, var(--color-border));
}

.result-verdict {
  margin: 0;
  font-size: 16px;
}

.result-verdict b {
  color: var(--color-accent);
}

/* 两种方式并排：窄屏也是左右两块，交得少的那块只在标题旁打「更划算」标签，不加亮 */
.plans {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.plan {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg);
}

.plan p {
  margin: 0;
}

.plan-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.plan-badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* 标题折行时两块的「年终奖到手」仍然对齐在底部 */
.plan-label {
  margin-top: auto;
  padding-top: 8px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.plan-net {
  font-size: clamp(20px, 6.4vw, 28px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

/* 全年到手排在年终奖到手下面，字号小一档，用细线和上面隔开 */
.plan .plan-label-year {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
}

.plan-year {
  font-size: clamp(16px, 5vw, 20px);
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

/* 全年到手的算式和各项金额，放在两块下面 */
.result-note {
  margin-top: 12px;
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.result-note p {
  margin: 0;
}

.result-note ul {
  margin: 4px 0;
  padding-left: 1.2em;
}

.result-note li {
  overflow-wrap: anywhere;
}

.plan-unit {
  margin-left: 3px;
  font-size: 13px;
  font-weight: 400;
  color: var(--color-text-muted);
}
.result-warning {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  font-size: 14px;
}

.result-hint {
  margin: 12px 0 0;
  color: var(--color-text-muted);
  font-size: 14px;
}

.result-hint:first-child {
  margin-top: 0;
}

/* 填写项 */

.field + .field {
  margin-top: 20px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 600;
}

.field-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-bg);
}

.field-input:focus-within {
  border-color: var(--color-focus);
}

.field-input input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap-min);
  border: 0;
  background: none;
  font-size: 17px;
}

.field-input input:focus {
  outline: none;
}

.field-unit {
  color: var(--color-text-muted);
  font-size: 14px;
}

.field-note {
  margin: 6px 0 0;
  color: var(--color-text-muted);
  font-size: 13px;
}

.field-error {
  margin: 6px 0 0;
  color: var(--color-accent);
  font-size: 13px;
}

/* 推算依据 */

.basis {
  margin-top: 10px;
}

.basis-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: var(--tap-min);
  padding: 6px 10px;
  border: 1px dashed var(--color-border);
  border-radius: 10px;
  background: none;
  color: var(--color-text-muted);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.basis-toggle-icon {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-accent) 14%, transparent);
  color: var(--color-accent);
}

.basis-restore {
  min-height: 32px;
  margin-top: 8px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: none;
  color: var(--color-text-muted);
  font-size: 13px;
  cursor: pointer;
}

/* 展开收起用 grid 行高从 0fr 到 1fr，高度不用写死也能过渡 */
.basis-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.22s ease;
}

.basis-wrap.is-open {
  grid-template-rows: 1fr;
}

/* 收起时设 visibility: hidden，旧 WebView 不认 inert 时也 Tab 不进里面的点选项 */
.basis-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, padding-top 0.22s ease, visibility 0s linear 0.22s;
}

.basis-wrap.is-open .basis-panel {
  padding-top: 12px;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.18s ease, padding-top 0.22s ease, visibility 0s;
}

.basis-note:empty {
  display: none;
}

.basis-note {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 13px;
}

.chips {
  margin: 0;
  padding: 0;
  border: 0;
}

.chips legend {
  padding: 0;
  margin-bottom: 8px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips legend {
  float: left;
  width: 100%;
}

.chip {
  display: inline-flex;
}

.chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.chip span {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
  min-height: var(--tap-min);
  padding: 0 14px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-bg);
  font-size: 14px;
  cursor: pointer;
}

.chip input:checked + span {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 14%, transparent);
  color: var(--color-accent);
  font-weight: 600;
}

.chip-deduction {
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 400;
}

.chip input:checked + span .chip-deduction {
  color: inherit;
}

.chip input:focus-visible + span {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

#city-group .chip span {
  flex: 1;
  padding: 0 10px;
  white-space: nowrap;
}

/* 一行四个，名字长的那个（其他城市）自己撑开，不换行挤成两行 */
#city-group .chip {
  flex: 1 0 auto;
  min-width: calc(25% - 6px);
}

/* 展开区、表格、说明 */

details[open] > *:not(summary) {
  animation: reveal 0.2s ease;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.more {
  margin-top: 20px;
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
}

summary {
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.rates {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.rates th,
.rates td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--color-border);
  text-align: right;
}

.rates th:first-child,
.rates td:first-child {
  text-align: left;
}

.rates thead th {
  color: var(--color-text-muted);
  font-weight: 500;
}

.rates tr.used {
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
}

.notes {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
}

.notes li + li {
  margin-top: 6px;
}

.notes-extra {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  font-size: 14px;
}

.footnote {
  color: var(--color-text-muted);
  font-size: 13px;
}

.footnote p {
  margin: 0 0 6px;
}

.footnote p:last-child {
  margin-bottom: 0;
}

.footnote a {
  color: var(--color-text-muted);
}

/* 宽屏：填写项在左，结果在右 */

@media (min-width: 768px) {
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    grid-template-areas: 'column result';
    align-items: start;
    gap: 20px;
  }

  .column {
    grid-area: column;
  }

  .result {
    grid-area: result;
    position: sticky;
    top: 72px;
  }

  #city-group .chip {
    flex: 0 1 auto;
  }
}
