/* ═══════════════════════════════════════════════
   Variables
═══════════════════════════════════════════════ */
:root {
  --blue:       #003087;
  --blue-mid:   #0041b8;
  --blue-light: #1a5fd4;
  --blue-pale:  #e8eef8;
  --red:        #E60012;
  --red-dark:   #b3000e;
  --white:      #ffffff;
  --off-white:  #f7f8fc;
  --navy:       #030d2b;

  --text-primary:   #0d1326;
  --text-secondary: #4a5270;
  --text-muted:     #8a91aa;
  --border:         #dde2ef;

  --shadow-sm:  0 1px 4px rgba(3,13,43,0.08);
  --shadow-md:  0 4px 16px rgba(3,13,43,0.12);
  --shadow-lg:  0 10px 32px rgba(3,13,43,0.18);
  --radius:     14px;
  --radius-sm:  8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Meiryo', sans-serif;
  background: var(--off-white);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════
   Tricolor top bar
═══════════════════════════════════════════════ */
body::before {
  content: '';
  display: block;
  height: 5px;
  background: linear-gradient(90deg,
    var(--blue) 0%,
    var(--blue) 40%,
    var(--white) 40%,
    var(--white) 60%,
    var(--red) 60%,
    var(--red) 100%
  );
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
}

/* ═══════════════════════════════════════════════
   Header
═══════════════════════════════════════════════ */
.site-header {
  position: sticky;
  top: 5px;   /* account for tricolor bar */
  z-index: 100;
  background: var(--navy);
  box-shadow: 0 2px 20px rgba(0,0,0,0.4);
}

/* Subtle diagonal grid overlay on header */
.site-header::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(
      -45deg,
      transparent 0px, transparent 18px,
      rgba(255,255,255,0.025) 18px, rgba(255,255,255,0.025) 19px
    );
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
  max-width: 1800px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Logo */
.header-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  text-decoration: none;
}

.logo-emblem {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-emblem img {
  display: block;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.4));
}


.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.logo-yokohama {
  color: var(--white);
}

.logo-text h1 em {
  font-style: normal;
  color: var(--blue-light);
}

.logo-text p {
  font-size: 0.62rem;
  color: var(--red);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 1px;
}

/* Controls */
.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 28px;
  overflow: hidden;
  transition: border-color 0.2s, background 0.2s;
}

.search-box:focus-within {
  background: rgba(255,255,255,0.14);
  border-color: rgba(230,0,18,0.6);
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: white;
  padding: 9px 16px;
  font-size: 0.88rem;
  width: 220px;
}

.search-box input::placeholder { color: rgba(255,255,255,0.38); }

.search-box button {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.search-box button:hover { color: var(--red); }

/* Update button */
.btn-crawl {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--red) 0%, #ff1a2e 100%);
  color: white;
  border: none;
  border-radius: 24px;
  padding: 9px 18px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  letter-spacing: 0.05em;
  box-shadow: 0 3px 10px rgba(230,0,18,0.35);
}

.btn-crawl:hover {
  background: linear-gradient(135deg, #cc000f 0%, var(--red) 100%);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(230,0,18,0.45);
}

.btn-crawl.loading .crawl-icon { animation: spin 0.8s linear infinite; }

/* Tricolor bottom bar on header */
.header-tricolor {
  height: 3px;
  background: linear-gradient(90deg,
    var(--blue) 0%, var(--blue) 40%,
    var(--white) 40%, var(--white) 60%,
    var(--red) 60%, var(--red) 100%
  );
}

/* Stats bar */
.header-stats {
  background: rgba(0,0,0,0.3);
  padding: 5px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

#statsText {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.06em;
}

/* Filter pills */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1.5px solid;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  background: transparent;
  letter-spacing: 0.04em;
}

.filter-pill[data-type="all"] {
  border-color: rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.6);
}

.filter-pill[data-type="news"] {
  border-color: rgba(0,48,135,0.6);
  color: rgba(120,160,255,0.85);
}

.filter-pill[data-type="youtube"] {
  border-color: rgba(255,0,0,0.5);
  color: rgba(255,120,120,0.9);
}

.filter-pill.active,
.filter-pill:hover {
  color: white;
  transform: translateY(-1px);
}

.filter-pill[data-type="all"].active     { background: rgba(255,255,255,0.15); border-color: white; }
.filter-pill[data-type="news"].active    { background: var(--blue); border-color: var(--blue); }
.filter-pill[data-type="youtube"].active { background: #FF0000;     border-color: #FF0000; }

/* ═══════════════════════════════════════════════
   Background pattern
═══════════════════════════════════════════════ */
main {
  max-width: 1800px;
  margin: 0 auto;
  padding: 24px 18px 50px;
}

/* ═══════════════════════════════════════════════
   Grid Layout
═══════════════════════════════════════════════ */
.masonry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
  align-items: start;
}

/* ═══════════════════════════════════════════════
   Cards
═══════════════════════════════════════════════ */
.card {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: transform 0.22s cubic-bezier(.25,.46,.45,.94),
              box-shadow 0.22s ease;
  cursor: pointer;
  position: relative;
  animation: fadeUp 0.35s ease both;
}

.card:hover {
  transform: translateY(-5px) scale(1.005);
  box-shadow: var(--shadow-lg);
}

.card:active { transform: translateY(-2px); }

/* Type indicator — left border glow on hover */
.card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--card-accent, var(--blue));
  opacity: 0;
  transition: opacity 0.2s;
  border-radius: 3px 0 0 3px;
}

.card:hover::before { opacity: 1; }

/* Media type accent colors */
.card[data-type="youtube"]    { --card-accent: #FF0000; }
.card[data-type="googlenews"] { --card-accent: #4285F4; }
.card[data-type="news"]       { --card-accent: var(--blue); }

/* Image */
.card-image-wrap {
  position: relative;
  overflow: hidden;
}

.card-image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.card:hover .card-image { transform: scale(1.04); }

/* YouTube play button overlay */
.card[data-type="youtube"] .card-image-wrap::after {
  content: '▶';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.7);
  background: rgba(0,0,0,0.18);
  opacity: 0;
  transition: opacity 0.2s;
}

.card[data-type="youtube"]:hover .card-image-wrap::after { opacity: 1; }

/* No-image fallback */
.card-no-image {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  position: relative;
  overflow: hidden;
}

/* Type-based gradients for no-image cards */
.card[data-type="news"]       .card-no-image { background: linear-gradient(135deg, #003087 0%, #001a5c 100%); }
.card[data-type="googlenews"] .card-no-image { background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%); }
.card[data-type="youtube"]    .card-no-image { background: linear-gradient(135deg, #cc0000 0%, #7a0000 100%); }

/* Tricolor stripe on no-image official cards */
.card[data-type="news"] .card-no-image::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue) 0% 33%, var(--white) 33% 66%, var(--red) 66% 100%);
}

/* Card body */
.card-body {
  padding: 13px 15px 15px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 9px 2px 7px;
  border-radius: 10px;
  color: white;
  letter-spacing: 0.02em;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-badge .badge-icon { font-size: 0.75rem; }

.card-date {
  font-size: 0.67rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.card-title {
  font-size: 0.91rem;
  font-weight: 700;
  line-height: 1.48;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s;
}

.card:hover .card-title { color: var(--blue-mid); }
.card[data-type="youtube"]:hover    .card-title { color: #cc0000; }
.card[data-type="googlenews"]:hover .card-title { color: #1a73e8; }

.card-desc {
  font-size: 0.77rem;
  color: var(--text-secondary);
  line-height: 1.58;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.card-link-hint {
  font-size: 0.67rem;
  color: var(--blue-light);
  opacity: 0;
  transition: opacity 0.18s;
}

.card:hover .card-link-hint { opacity: 1; }

.card[data-type="youtube"]:hover    .card-link-hint { color: #FF0000; }
.card[data-type="googlenews"]:hover .card-link-hint { color: #1a73e8; }

/* ═══════════════════════════════════════════════
   Loading & States
═══════════════════════════════════════════════ */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 36px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.loader.hidden { display: none; }

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-right-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.sentinel { height: 80px; }

.end-message, .empty-message {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.end-message {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.end-message::before {
  content: '';
  flex: 1;
  max-width: 120px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border));
}

.end-message::after {
  content: '';
  flex: 1;
  max-width: 120px;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

.end-message.hidden, .empty-message.hidden { display: none; }

.empty-icon { font-size: 3rem; margin-bottom: 14px; }
.empty-message p { margin-bottom: 18px; }

.btn-reset {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 22px;
  padding: 9px 22px;
  cursor: pointer;
  font-size: 0.83rem;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-reset:hover { background: var(--blue-mid); }

/* ═══════════════════════════════════════════════
   Back to Top
═══════════════════════════════════════════════ */
.back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--navy) 100%);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(3,13,43,0.3),
              inset 0 1px 1px rgba(255,255,255,0.15);
  transition: all 0.22s;
  z-index: 50;
}

.back-to-top:hover {
  background: linear-gradient(135deg, var(--blue-mid) 0%, var(--blue) 100%);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(3,13,43,0.35);
}

.back-to-top.hidden { opacity: 0; pointer-events: none; transform: translateY(10px); }

/* ═══════════════════════════════════════════════
   Animations
═══════════════════════════════════════════════ */
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════
   Skeleton
═══════════════════════════════════════════════ */
.card-skeleton {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.skeleton-img {
  width: 100%;
  height: 155px;
  background: linear-gradient(90deg, #eceef6 25%, #f5f6fb 50%, #eceef6 75%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-body { padding: 13px 15px; }

.skeleton-line {
  height: 11px;
  border-radius: 6px;
  background: linear-gradient(90deg, #eceef6 25%, #f5f6fb 50%, #eceef6 75%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  margin-bottom: 9px;
}

.skeleton-line.short  { width: 55%; }
.skeleton-line.medium { width: 80%; }
.skeleton-line.long   { width: 100%; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Contact link */
.contact-link {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.8rem;
  white-space: nowrap;
}
.contact-link:hover { color: #fff; }

/* Footer */
.site-footer {
  text-align: center;
  padding: 20px;
  font-size: 0.85rem;
}
.site-footer a {
  color: var(--gray);
  text-decoration: none;
}
.site-footer a:hover { color: var(--blue); }

/* Ad */
.ad-infeed {
  grid-column: 1 / -1;
  text-align: center;
  padding: 12px 0;
}

.ad-sticky {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  text-align: center;
  background: rgba(255,255,255,0.95);
  padding: 4px 0;
  z-index: 999;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

/* ═══════════════════════════════════════════════
   Responsive
═══════════════════════════════════════════════ */
@media (max-width: 680px) {
  .header-inner { padding: 11px 14px; gap: 10px; flex-wrap: wrap; }
  .logo-text h1 { font-size: 1rem; }
  .logo-text p  { font-size: 0.65rem; }
  .header-controls { width: 100%; justify-content: space-between; }
  .search-box { flex: 1; }
  .search-box input { width: 100%; font-size: 0.82rem; box-sizing: border-box; }
  .filter-bar { display: none; }
  main { padding: 16px 10px 40px; }
  .masonry-grid { gap: 10px; grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .logo-emblem { width: 36px; height: 36px; }
  .logo-emblem span { font-size: 1.2rem; }
  .search-box input { width: 100px; }
}
