/* AT News Japan — 白基調・大きな角丸・ピル型の検索バー（コントラストは WCAG 2.2 AA を満たす値） */
:root {
  --bg: #ffffff;
  --surface: #f7f7f7;
  --text: #222222;
  --muted: #6a6a6a;
  --line: #dddddd;
  --line-strong: #8c8c8c; /* 操作部品の境界（3:1以上） */
  --accent-text: #de1a4f; /* 白地で 4.81:1 */
  --accent-grad: linear-gradient(90deg, #e61e4d 0%, #d70466 100%);
  --on-accent: #ffffff;
  --focus: #222222;
  --focus-halo: #ffffff;
  --shadow: 0 1px 2px rgb(0 0 0 / 8%), 0 4px 12px rgb(0 0 0 / 5%);
  --shadow-raised: 0 6px 20px rgb(0 0 0 / 12%);
  --tone-company: #fdecef;
  --tone-standards: #e8f0fe;
  --tone-organization: #e7f6ec;
  --tone-community: #f1ecfb;
  --tone-japan: #fff4e0;
  --tone-text: #222222;
  --tag-bg: #ffffff;
  --radius-card: 1rem;
  --radius-pill: 999px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1c1c1c;
    --text: #f2f2f2;
    --muted: #b0b0b0;
    --line: #333333;
    --line-strong: #8c8c8c;
    --accent-text: #ff7a99;
    --focus: #ffffff;
    --focus-halo: #121212;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-raised: 0 6px 20px rgb(0 0 0 / 55%);
    --tone-company: #3a2027;
    --tone-standards: #1f2a3d;
    --tone-organization: #1d3326;
    --tone-community: #2c2440;
    --tone-japan: #3a2f1c;
    --tone-text: #f2f2f2;
    --tag-bg: #121212;
    color-scheme: dark;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 1rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover {
  text-decoration-thickness: 2px;
}

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--focus-halo);
}
main:focus,
[tabindex="-1"]:focus:not(:focus-visible) {
  outline: none;
}

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: -10rem;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--focus);
  border-radius: var(--radius-pill);
  font-weight: 700;
}
.skip-link:focus {
  top: 0.75rem;
}

/* ヘッダー */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 2rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}
.site-name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.site-name a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent-text);
  text-decoration: none;
  min-height: 2.75rem;
}
.logo-mark {
  width: 2rem;
  height: 2rem;
  stroke-width: 2;
}
.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  padding: 0.25rem 0.875rem;
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
.site-nav a:hover {
  background: var(--surface);
  color: var(--text);
}
.site-nav a[aria-current="page"] {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.45em;
}

main {
  padding: 2rem 0 4rem;
}

h1 {
  font-size: clamp(1.625rem, 1.2rem + 1.6vw, 2.25rem);
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}
h2 {
  font-size: 1.375rem;
  line-height: 1.4;
  margin: 2.5rem 0 1rem;
}
.lead {
  color: var(--muted);
  margin: 0 0 1.5rem;
  max-width: 44rem;
}

/* ヒーロー：種類タブ＋検索バー */
.hero {
  text-align: center;
  padding: 0.5rem 0 1rem;
}
.hero .lead {
  margin-left: auto;
  margin-right: auto;
}

.type-nav ul {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}
.type-nav a {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 5.5rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem 0.625rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.type-nav .icon {
  width: 1.75rem;
  height: 1.75rem;
}
.type-nav a:hover {
  color: var(--text);
  border-bottom-color: var(--line-strong);
}
.type-nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--text);
}

.search-bar {
  display: flex;
  align-items: stretch;
  max-width: 64rem;
  margin: 0 auto;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-raised);
}
.segment {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1 1 0;
  min-width: 0;
  padding: 0.625rem 1.5rem;
  border-radius: var(--radius-pill);
}
.segment-wide {
  flex: 1.6 1 0;
}
.segment + .segment::before {
  content: "";
  position: absolute;
  left: 0;
  top: 25%;
  bottom: 25%;
  border-left: 1px solid var(--line);
}
.segment:hover {
  background: var(--surface);
}
.segment:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}
.segment label {
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.4;
}
.segment input,
.segment select {
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: transparent;
  border: 0;
  padding: 0.125rem 0;
  min-height: 1.75rem;
  width: 100%;
}
.segment input::placeholder {
  color: var(--muted);
  opacity: 1;
}
.segment select {
  appearance: none;
  padding-right: 1.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238c8c8c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
  background-size: 1rem;
  cursor: pointer;
}
.segment select option {
  background: var(--bg);
  color: var(--text);
}
.segment input:focus-visible,
.segment select:focus-visible {
  outline: none;
  box-shadow: none;
}
.search-submit {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.5rem 0.5rem 0.25rem;
}
button {
  font: inherit;
  cursor: pointer;
}
.search-submit button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 3rem;
  padding: 0 1.25rem;
  color: var(--on-accent);
  background: var(--accent-grad);
  border: 0;
  border-radius: var(--radius-pill);
  font-weight: 700;
  white-space: nowrap;
}
.search-submit button:hover {
  filter: brightness(0.92);
}
.search-footer {
  max-width: 64rem;
  margin: 0.75rem auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  text-align: left;
  font-size: 0.8125rem;
  color: var(--muted);
}
.search-footer p {
  margin: 0;
}
.search-footer .clear a {
  color: var(--text);
  font-weight: 700;
}

.result-status {
  margin: 2rem 0 0;
  font-weight: 700;
}
.results > h2 {
  margin-top: 0.75rem;
}

/* カード */
.results[aria-busy="true"] {
  opacity: 0.55;
}
.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: 2rem 1.5rem;
}
.card article {
  display: flex;
  flex-direction: column;
  height: 100%;
}
/* 読み上げ順は「見出し→情報源→日付→本文」、見た目は「パネル→日付→見出し→本文」 */
.card-visual {
  order: -2;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 9.5rem;
  margin-bottom: 0.875rem;
  padding: 1rem 1.125rem;
  border-radius: var(--radius-card);
  color: var(--tone-text);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover .card-visual,
.card:focus-within .card-visual {
  box-shadow: var(--shadow-raised);
  transform: translateY(-2px);
}
.tone-company { background: var(--tone-company); }
.tone-standards { background: var(--tone-standards); }
.tone-organization { background: var(--tone-organization); }
.tone-community { background: var(--tone-community); }
.tone-japan { background: var(--tone-japan); }
.card-icon {
  position: absolute;
  right: 1rem;
  top: 1rem;
  width: 2.25rem;
  height: 2.25rem;
  opacity: 0.8;
}
.card-source {
  margin: 0;
  padding-right: 3rem;
  font-weight: 700;
  line-height: 1.5;
}
.card-country {
  display: block;
  font-size: 0.8125rem;
  font-weight: 400;
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.tags li {
  background: var(--tag-bg);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 0.125rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.6;
  box-shadow: var(--shadow);
}
.card-date {
  order: -1;
  margin: 0 0 0.125rem;
  font-size: 0.8125rem;
  color: var(--muted);
}
.card-title {
  font-size: 1.0625rem;
  line-height: 1.55;
  margin: 0;
}
.orig-title {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}
.summary {
  margin: 0.625rem 0 0.75rem;
  font-size: 0.9375rem;
}
.read-more {
  margin: auto 0 0;
  font-size: 0.9375rem;
  font-weight: 700;
}
.read-more a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--accent-text);
  min-height: 2.75rem;
}
.read-more .icon {
  width: 1em;
  height: 1em;
}

/* ページ送り */
.pagination ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  list-style: none;
  margin: 3rem 0 0;
  padding: 0;
  align-items: center;
}
.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0 0.875rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  text-decoration: none;
}
.pagination a:hover {
  background: var(--surface);
  text-decoration: underline;
}
.pagination a[aria-current="page"] {
  background: var(--text);
  color: var(--bg);
}

/* 情報源ページ・本文ページ */
.source-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
  gap: 1.25rem;
}
.source {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}
.source h3 {
  font-size: 1.0625rem;
  margin: 0 0 0.5rem;
}
.meta {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.meta-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.5rem;
}
.meta dt {
  font-weight: 700;
  color: var(--text);
}
.meta dt::after {
  content: "：";
}
.meta dd {
  margin: 0;
}
.meta a {
  color: var(--accent-text);
  font-weight: 700;
}
.state-error {
  font-weight: 700;
  color: var(--accent-text);
}
.source .read-more {
  margin-top: 0.5rem;
  font-weight: 400;
}
.prose p,
.prose li {
  max-width: 44rem;
}
.prose a {
  color: var(--accent-text);
}

.empty {
  padding: 3rem 1rem;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius-card);
}
.empty a {
  color: var(--accent-text);
  font-weight: 700;
}

/* フッター */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 2rem 0;
  font-size: 0.875rem;
}
.site-footer p {
  margin: 0 0 0.75rem;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
}
.footer-links a {
  display: inline-block;
  min-height: 2.75rem;
  line-height: 2.75rem;
}
.copyright {
  color: var(--muted);
}

/* 狭い画面：検索バーを縦に積む */
@media (max-width: 52rem) {
  .search-bar {
    flex-direction: column;
    border-radius: 1.5rem;
  }
  .segment {
    border-radius: 1.5rem;
    padding: 0.75rem 1.25rem;
  }
  .segment + .segment::before {
    left: 1.25rem;
    right: 1.25rem;
    top: 0;
    bottom: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .search-submit {
    padding: 0.5rem 0.75rem 0.75rem;
  }
  .search-submit button {
    width: 100%;
  }
  .type-nav ul {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.25rem;
  }
  .type-nav a {
    display: flex;
    min-width: 0;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }
  .hero {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .card:hover .card-visual,
  .card:focus-within .card-visual {
    transform: none;
  }
}

@media (forced-colors: active) {
  .search-bar,
  .card-visual,
  .tags li,
  .source {
    border: 1px solid CanvasText;
  }
  .search-submit button,
  .pagination a[aria-current="page"] {
    border: 2px solid ButtonText;
  }
}
