/*
 * 本文件用于给双板滑雪脱离值工具提供页面样式：顶栏、摘要条、档位方块、Type 问答和结果页。
 * 配色和字体用 /shared/base.css 里的变量。改了本文件要同步改 sw.js 里的缓存版本号。
 */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.noscript {
  padding-block: 48px;
  text-align: center;
}

/* ---------- 顶栏和摘要条 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 52px;
  padding-top: env(safe-area-inset-top);
}

.topbar-back {
  display: grid;
  flex: none;
  place-items: center;
  width: var(--tap-min);
  height: var(--tap-min);
  margin-left: -10px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

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

/* 第一步没有返回按钮，标题靠左和其他工具对齐 */
.topbar-back[hidden] {
  display: none;
}

.topbar-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-home {
  display: grid;
  flex: none;
  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);
}

.summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding-bottom: 8px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: var(--tap-min);
  padding: 6px 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
  cursor: pointer;
}

.summary-item:hover {
  background: color-mix(in srgb, var(--color-text) 6%, transparent);
}

.summary-label {
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.2;
}

.summary-value {
  max-width: 100%;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-item.is-empty .summary-value {
  color: var(--color-text-muted);
  font-weight: 400;
  opacity: 0.6;
}

.summary-item[aria-current="step"] {
  border-bottom-color: var(--color-accent);
}

.summary-item[aria-current="step"] .summary-label {
  color: var(--color-accent);
}

/* ---------- 每一步的内容区 ---------- */

.view {
  padding-block: 24px 48px;
  outline: none;
}

.view-enter {
  animation: view-enter 0.22s ease-out;
}

@keyframes view-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.step-heading {
  margin: 0 0 4px;
  font-size: 22px;
  line-height: 1.35;
}

.step-hint {
  margin: 0 0 20px;
  color: var(--color-text-muted);
  font-size: 15px;
}

.tile-grid {
  display: grid;
  /* 360px 宽的手机上正好排三列，和 rentmaxx 一样一屏看完体重档 */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 96px), 1fr));
  gap: 10px;
}

.tile-grid.is-wide {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  padding: 12px 10px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}

.tile:hover:not([aria-disabled="true"]) {
  border-color: color-mix(in srgb, var(--color-accent) 55%, var(--color-border));
}

.tile:active:not([aria-disabled="true"]) {
  transform: scale(0.98);
}

.tile-sub {
  display: block;
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 400;
}

.tile.is-wide {
  align-items: flex-start;
  text-align: left;
}

.tile[aria-pressed="true"] {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
}

.tile[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}

.tile[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
}

.tile-reason {
  display: block;
  margin-top: 4px;
  color: var(--color-accent);
  font-size: 13px;
  font-weight: 400;
}

.link-button {
  min-height: var(--tap-min);
  margin-top: 16px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--color-accent);
  font-size: 15px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.note {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--color-text) 5%, transparent);
  color: var(--color-text-muted);
  font-size: 14px;
}

.note.is-warning {
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
  color: var(--color-text);
}

.quiz-progress {
  margin: 0 0 8px;
  color: var(--color-accent);
  font-size: 14px;
  font-weight: 600;
}

.verdict {
  padding: 20px;
  border: 1.5px solid var(--color-accent);
  border-radius: 16px;
  background: var(--color-surface);
}

.verdict-type {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
}

.verdict-description {
  margin: 8px 0 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.button {
  display: inline-flex;
  flex: 1 1 160px;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 1.5px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.button.is-primary {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

.sole-guide {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 0 0 20px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--color-text) 5%, transparent);
  font-size: 14px;
}

.sole-guide svg {
  flex: none;
  color: var(--color-text-muted);
}

/* ---------- 结果页 ---------- */

.result-hero {
  display: grid;
  place-items: center;
  padding: 8px 0 4px;
  text-align: center;
}

.binding {
  position: relative;
  width: min(100%, 300px);
}

.binding svg {
  display: block;
  width: 100%;
  height: auto;
  color: color-mix(in srgb, var(--color-text) 22%, var(--color-surface));
}

.binding-value {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
}

.binding-number {
  font-size: clamp(64px, 20vw, 88px);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.binding-caption {
  margin-top: 6px;
  color: var(--color-text-muted);
  font-size: 14px;
}

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

.result-section {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  background: var(--color-surface);
}

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

.range-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 10px;
}

.range-item {
  padding: 12px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--color-text) 4%, transparent);
}

.range-label {
  display: block;
  color: var(--color-text-muted);
  font-size: 13px;
}

.range-value {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.range-center {
  display: block;
  color: var(--color-text-muted);
  font-size: 13px;
}

.safety {
  margin-top: 20px;
  padding: 16px 18px;
  border-left: 4px solid var(--color-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: color-mix(in srgb, var(--color-accent) 9%, var(--color-surface));
}

.safety strong {
  display: block;
  margin-bottom: 4px;
}

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

.copy-fallback {
  width: 100%;
  min-height: 180px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
}

.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 20;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--color-text);
  color: var(--color-bg);
  font-size: 15px;
  transform: translateX(-50%);
  animation: view-enter 0.2s ease-out;
}
