/* 科學網站分享 — 校園友善樣式（軟綠／軟藍） */
:root {
  --bg: #f2f7fb;
  --card: #ffffff;
  --primary: #2d8a6e;
  --primary-dark: #1f6b54;
  --primary-light: #e7f6ef;
  --blue: #3d7ea6;
  --blue-dark: #2a6286;
  --blue-soft: #e7f2f8;
  --text: #1a2c33;
  --muted: #5c727a;
  --border: #d3e3ea;
  --danger: #c2524a;
  --danger-soft: #fdeceb;
  --success: #1f8a72;
  --success-soft: #e7f7f2;
  --shadow: 0 8px 24px rgba(45, 110, 140, 0.1);
  --radius: 16px;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(ellipse at top left, #d9f0e6 0%, transparent 52%),
    radial-gradient(ellipse at bottom right, #d7ebf6 0%, transparent 48%),
    var(--bg);
  line-height: 1.55;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  background: #fff;
  color: var(--primary-dark);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  z-index: 5;
}

.skip-link:focus {
  top: 0.75rem;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.site-header {
  text-align: center;
  margin-bottom: 1.25rem;
  padding: 1.35rem 1rem 1.15rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--blue) 100%);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  opacity: 0.92;
}

.site-header h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.45rem, 4.4vw, 2rem);
  font-weight: 700;
}

.subtitle {
  margin: 0 auto;
  max-width: 36rem;
  opacity: 0.96;
  font-size: 0.98rem;
}

.page-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.95rem;
}

.page-nav-link {
  text-decoration: none;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.45);
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.page-nav-link:hover,
.page-nav-link:focus-visible {
  background: rgba(255, 255, 255, 0.28);
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.15rem 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card h2,
.card h3 {
  color: var(--primary-dark);
}

.card h2 {
  margin: 0;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.section-lead {
  margin: 0.35rem 0 1rem;
  color: var(--muted);
}

.filter-block + .filter-block {
  margin-top: 0.9rem;
}

.filter-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.chip-row,
.chip-group .chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip-group {
  margin-bottom: 0.65rem;
}

.chip-group-label {
  margin: 0 0 0.3rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--blue-dark);
}

.chip {
  appearance: none;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  min-height: 40px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  white-space: normal;
  text-align: left;
  line-height: 1.35;
  max-width: 100%;
}

.chip:hover {
  border-color: var(--blue);
}

.chip:focus-visible {
  outline: 3px solid rgba(61, 126, 166, 0.35);
  outline-offset: 1px;
}

.chip.is-on {
  background: var(--blue-soft);
  border-color: var(--blue);
  color: var(--blue-dark);
}

.chip.is-on.chip-grade {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

label,
.field-label {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 0.35rem;
}

.hint,
.req {
  font-weight: 600;
  font-size: 0.78rem;
}

.hint {
  color: var(--muted);
}

.req {
  color: var(--blue-dark);
}

input[type="url"],
input[type="text"],
input[type="search"],
input[type="password"],
textarea {
  width: 100%;
  padding: 0.72rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 5.2rem;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 138, 110, 0.18);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.form-grid {
  display: grid;
  gap: 0.95rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.form-grid .actions .btn-primary {
  width: auto;
  flex: 1 1 12rem;
}

.form-grid .actions .btn-secondary {
  flex: 1 1 8rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.72rem 1rem;
  border-radius: 12px;
  border: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(45, 138, 110, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--blue-soft);
  color: var(--blue-dark);
  padding: 0.45rem 0.8rem;
  min-height: 40px;
  font-size: 0.88rem;
}

.btn-secondary:hover:not(:disabled) {
  background: #d5e8f3;
}

.btn-primary.btn-inline {
  width: auto;
  min-width: 8rem;
}

.btn-quiet {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-quiet:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.btn-quiet-danger {
  background: #fff;
  color: var(--danger);
  border: 1.5px solid #f0c2bd;
}

.btn-quiet-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #a8433c;
}

.btn-ghost {
  background: transparent;
  color: var(--primary-dark);
  border: 1.5px solid rgba(31, 107, 84, 0.35);
  min-height: 40px;
  padding: 0.35rem 0.75rem;
}

.text-btn {
  appearance: none;
  border: none;
  background: none;
  color: var(--blue-dark);
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  padding: 0.2rem 0;
}

.text-link {
  color: var(--blue-dark);
  font-weight: 700;
}

.result-meta {
  margin: 0.95rem 0 0.7rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.card-list {
  display: grid;
  gap: 0.8rem;
}

.site-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem 0.9rem 0.85rem;
  background: linear-gradient(180deg, #f8fcff 0%, #fff 42%);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.site-card.is-new {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 138, 110, 0.18);
}

.grade-row,
.topic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.pill-grade {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.pill-topic {
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.pill-demo {
  background: #fff4df;
  color: #8a5a12;
}

.card-title {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  line-height: 1.4;
}

.card-title:hover,
.card-title:focus-visible {
  color: var(--blue-dark);
  text-decoration: underline;
}

.host {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  word-break: break-all;
}

.note {
  margin: 0;
  font-size: 0.92rem;
}

.meta-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.open-link {
  margin-top: 0.25rem;
  background: var(--blue);
  color: #fff;
}

.open-link:hover {
  background: var(--blue-dark);
}

.empty-state {
  margin: 0;
  padding: 1rem 0.2rem 0.3rem;
  color: var(--muted);
}

.feedback {
  display: none;
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
}

.feedback.visible {
  display: block;
}

.feedback.success {
  background: var(--success-soft);
  border: 2px solid #b7e4d6;
}

.feedback.error {
  background: var(--danger-soft);
  border: 2px solid #f3c2bc;
}

.feedback .title {
  margin: 0 0 0.25rem;
  font-weight: 700;
}

.feedback .msg {
  margin: 0;
}

.mock-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 1rem;
  padding: 0.8rem 0.95rem;
  background: #fff8ea;
  border: 1.5px solid #f0d7a2;
  border-radius: 14px;
  color: #6d5316;
}

.mock-banner p {
  margin: 0;
  flex: 1 1 16rem;
}

.mock-banner[hidden] {
  display: none;
}

.footer-note {
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.footer-note p {
  margin: 0;
}

.manage-hint,
.unlock-status {
  margin: 0 0 0.75rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.form-error {
  margin: 0.4rem 0 0;
  color: var(--danger);
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(26, 44, 51, 0.48);
}

.modal-card {
  width: min(100%, 26rem);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: #fff;
  border-radius: var(--radius);
  padding: 1.15rem 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 0 0 0.45rem;
  color: var(--primary-dark);
  font-size: 1.15rem;
}

.modal-card p {
  margin: 0;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.modal-actions .btn {
  flex: 1 1 8rem;
}

#list-feedback.visible {
  margin-bottom: 0.75rem;
  font-weight: 700;
}

details.strand {
  border-top: 1px solid var(--border);
  margin-top: 0.35rem;
  padding-top: 0.15rem;
}

details.strand summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--primary-dark);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.qr-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.35rem;
}

.qr-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.45rem 0.45rem 0.35rem;
}

.qr-canvas {
  width: 132px;
  height: 132px;
  image-rendering: pixelated;
}

.qr-caption {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--blue-dark);
}

.qr-actions,
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.card-actions .btn,
.qr-actions .btn {
  min-height: 40px;
  padding: 0.4rem 0.7rem;
  font-size: 0.88rem;
}

.feedback-qr {
  margin-top: 0.75rem;
}

.feedback-qr[hidden] {
  display: none;
}

.print-sheet {
  display: none;
}

@media print {
  body * {
    visibility: hidden !important;
  }

  .print-sheet,
  .print-sheet * {
    visibility: visible !important;
  }

  .print-sheet {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background: #fff;
    color: #000;
    text-align: center;
    padding: 18mm 12mm;
  }

  .print-kicker,
  .print-url {
    margin: 0.4rem 0;
  }

  .print-sheet h1 {
    font-size: 1.4rem;
    margin: 0.4rem 0 1rem;
  }

  .print-sheet canvas {
    width: 280px !important;
    height: 280px !important;
  }
}

@media (min-width: 760px) {
  .card {
    padding: 1.3rem 1.35rem 1.4rem;
  }

  .card-list {
    grid-template-columns: 1fr 1fr;
  }

  .site-card {
    min-height: 100%;
  }
}
