/*
Theme Name: 競馬新聞.com
Theme URI: https://keiba-news.com
Author: B-Side Funny
Author URI: https://bsidefunny.com
Description: JRA中央競馬G1・G2・G3重賞レース専門予想新聞サイト用WordPressテーマ
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: keiba-news
Requires at least: 6.0
Requires PHP: 8.0
*/

/* ===== CSS VARIABLES ===== */
:root {
  --crimson: #8B1A1A;
  --crimson-dark: #5C0A0A;
  --crimson-light: #C0392B;
  --gold: #C9A84C;
  --gold-light: #F0D080;
  --gold-pale: #FFF8E7;
  --charcoal: #1C1C1C;
  --ink: #2D2D2D;
  --gray-dark: #444;
  --gray-mid: #888;
  --gray-light: #DDD;
  --gray-pale: #F5F5F5;
  --white: #FAFAF8;
  --g1-color: #8B1A1A;
  --g2-color: #1A4D8B;
  --g3-color: #1A6B3C;
  --shadow: 0 2px 12px rgba(0,0,0,0.12);
  --shadow-deep: 0 4px 24px rgba(0,0,0,0.2);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--gray-pale);
  color: var(--ink);
  min-height: 100vh;
}

/* ===== HEADER ===== */
.site-header {
  background: linear-gradient(135deg, var(--crimson-dark) 0%, var(--crimson) 60%, #A52A2A 100%);
  position: relative;
  overflow: hidden;
}

.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 20px,
    rgba(255,255,255,0.03) 20px,
    rgba(255,255,255,0.03) 40px
  );
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 16px;
  position: relative;
  z-index: 1;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  text-decoration: none;
}

.logo-mark {
  width: 52px;
  height: 52px;
  background: var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Noto Serif JP', serif;
  font-weight: 900;
  font-size: 22px;
  color: var(--crimson-dark);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.logo-text h1,
.logo-text .site-title {
  font-family: 'Noto Serif JP', serif;
  font-weight: 900;
  font-size: 28px;
  color: var(--white);
  letter-spacing: 0.05em;
  line-height: 1;
  margin: 0;
}

.logo-text .tagline {
  font-size: 11px;
  color: var(--gold-light);
  letter-spacing: 0.1em;
  margin-top: 3px;
}

nav.main-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

nav.main-nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  transition: all 0.2s;
}

nav.main-nav a:hover {
  background: rgba(255,255,255,0.15);
  color: var(--white);
}

/* ===== YEAR TABS ===== */
.year-tabs {
  background: var(--charcoal);
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.year-tabs::-webkit-scrollbar { display: none; }

.year-tab {
  flex-shrink: 0;
  padding: 10px 24px;
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
}

.year-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.year-tab:hover { color: rgba(255,255,255,0.8); }

/* ===== ARCHIVE BAR ===== */
.archive-bar {
  background: var(--charcoal);
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  text-align: center;
  padding: 8px 16px;
  letter-spacing: 0.05em;
}

.archive-bar a { color: var(--gold-light); text-decoration: none; }
.archive-bar strong { color: var(--gold-light); }

/* ===== MAIN CONTENT ===== */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

/* ===== INFO BAR ===== */
.info-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1px solid var(--gray-light);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.today-badge {
  background: var(--crimson);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.current-date {
  font-size: 13px;
  color: var(--gray-dark);
  font-weight: 500;
}

.legend {
  display: flex;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--gray-dark);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* ===== UPCOMING HIGHLIGHT ===== */
.upcoming-section {
  background: linear-gradient(135deg, var(--crimson-dark), #8B3A3A);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
  color: white;
  box-shadow: var(--shadow-deep);
}

.upcoming-title {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--gold-light);
  margin-bottom: 10px;
  text-transform: uppercase;
}

.upcoming-races {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}

.upcoming-race-card {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 10px 12px;
  text-decoration: none;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s;
  cursor: pointer;
}

.upcoming-race-card:hover {
  background: rgba(255,255,255,0.2);
}

.upcoming-race-card .urc-date {
  font-size: 18px;
  font-weight: 700;
  font-family: 'Noto Serif JP', serif;
  line-height: 1;
}

.upcoming-race-card .urc-month {
  font-size: 10px;
  color: var(--gold-light);
}

.upcoming-race-card .urc-info { flex: 1; }

.upcoming-race-card .urc-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.upcoming-race-card .urc-venue {
  font-size: 10px;
  color: rgba(255,255,255,0.65);
  margin-top: 2px;
}

.urc-grade {
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: 700;
}

/* ===== MONTH SECTION ===== */
.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.month-section {
  background: var(--white);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-light);
}

.month-header {
  background: linear-gradient(to right, var(--charcoal), #3A3A3A);
  color: white;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: default;
  user-select: none;
}

.month-header.accordion {
  cursor: pointer;
  opacity: 0.72;
  transition: opacity 0.2s;
}

.month-header.accordion:hover { opacity: 0.9; }

.month-name {
  font-family: 'Noto Serif JP', serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.month-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-count {
  font-size: 11px;
  color: var(--gold-light);
  background: rgba(255,255,255,0.1);
  padding: 2px 8px;
  border-radius: 10px;
}

.month-past-label {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.05em;
}

.accordion-arrow {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  transition: transform 0.3s;
  display: inline-block;
}

.accordion-arrow.open { transform: rotate(180deg); }

/* ===== RACE LIST ===== */
.race-list {
  padding: 6px 0;
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.3s ease;
}

.race-list.collapsed {
  max-height: 0 !important;
  padding: 0;
  opacity: 0;
}

/* ===== RACE ROW ===== */
.race-row {
  display: flex;
  align-items: center;
  padding: 7px 14px;
  gap: 10px;
  border-bottom: 1px solid #F0F0F0;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
  position: relative;
}

.race-row:last-child { border-bottom: none; }

.race-row.available { cursor: pointer; }
.race-row.available:hover { background: var(--gold-pale); }
.race-row.past { opacity: 0.5; cursor: default; }

.race-date {
  font-size: 12px;
  color: var(--gray-mid);
  min-width: 60px;
  flex-shrink: 0;
  line-height: 1.3;
}

.race-date .weekday { font-size: 10px; }
.race-date .weekday.sun { color: #C0392B; }
.race-date .weekday.sat { color: #1A5EA8; }

.grade-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 28px;
  text-align: center;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

.g1 { background: var(--g1-color); color: white; }
.g2 { background: var(--g2-color); color: white; }
.g3 { background: var(--g3-color); color: white; }

.race-name-cell {
  font-size: 13px;
  font-weight: 700;
  flex: 1;
  line-height: 1.3;
}

.race-name-cell .sub {
  font-size: 10px;
  font-weight: 400;
  color: var(--gray-mid);
  display: block;
}

.race-venue {
  font-size: 10px;
  color: var(--gray-mid);
  min-width: 30px;
  text-align: right;
  flex-shrink: 0;
}

.race-status {
  font-size: 10px;
  flex-shrink: 0;
  min-width: 44px;
  text-align: right;
}

.status-available {
  background: var(--crimson);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.status-soon {
  background: #E67E22;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.status-waiting {
  color: var(--gray-mid);
  font-size: 10px;
}
.status-past { color: var(--gray-light); font-size: 12px; }

/* ===== G1 HIGHLIGHT ===== */
.race-row.g1-race {
  background: linear-gradient(to right, rgba(139,26,26,0.04), transparent);
}
.race-row.g1-race .race-name-cell { color: var(--crimson); }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--white);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 0;
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--gray-light);
  border-radius: 2px;
  margin: 12px auto 0;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-light);
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-grade { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 5px; }

.modal-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 20px;
  font-weight: 700;
  flex: 1;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gray-pale);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-dark);
}

.modal-meta {
  display: flex;
  gap: 16px;
  padding: 12px 20px;
  background: var(--gray-pale);
  flex-wrap: wrap;
}

.meta-item { font-size: 12px; }
.meta-label { color: var(--gray-mid); margin-right: 4px; }
.meta-value { font-weight: 600; }

.shinbun-preview { padding: 20px; }

.shinbun-header {
  background: linear-gradient(135deg, var(--crimson-dark), var(--crimson));
  color: white;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 16px;
  text-align: center;
}

.shinbun-header h2 {
  font-family: 'Noto Serif JP', serif;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.shinbun-header p {
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  margin-top: 6px;
}

.shinbun-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.shinbun-card {
  border: 1px solid var(--gray-light);
  border-radius: 8px;
  padding: 14px;
}

.shinbun-card h3 {
  font-size: 12px;
  color: var(--gray-mid);
  letter-spacing: 0.1em;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gray-light);
}

.horse-list { list-style: none; }

.horse-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px dashed #EEE;
}

.horse-list li:last-child { border-bottom: none; }

.horse-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--crimson);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.horse-num.gold { background: var(--gold); color: var(--crimson-dark); }
.horse-num.silver { background: #888; }
.horse-num.bronze { background: #C87941; }

.btn-read-full {
  display: block;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--crimson-dark), var(--crimson));
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Noto Sans JP', sans-serif;
  letter-spacing: 0.05em;
  transition: opacity 0.2s;
  text-decoration: none;
  text-align: center;
}

.btn-read-full:hover { opacity: 0.9; color: white; }

/* ===== FOOTER ===== */
.site-footer {
  background: var(--charcoal);
  color: rgba(255,255,255,0.6);
  padding: 30px 16px 24px;
  margin-top: 40px;
  text-align: center;
}

.footer-logo {
  font-family: 'Noto Serif JP', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 12px;
}

.footer-links {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.footer-links a {
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 12px;
}

.footer-copy { font-size: 11px; color: rgba(255,255,255,0.3); }

/* ===== SCROLL TO TOP ===== */
.scroll-top {
  position: fixed;
  bottom: 20px;
  right: 16px;
  width: 44px;
  height: 44px;
  background: var(--crimson);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-deep);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: opacity 0.2s;
}

.scroll-top.visible { display: flex; }

/* ===== SINGLE POST (RACE NEWSPAPER) ===== */
.single-race-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

.back-to-top-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--crimson);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
  padding: 6px 12px;
  border: 1px solid var(--crimson);
  border-radius: 6px;
  transition: all 0.2s;
}

.back-to-top-link:hover {
  background: var(--crimson);
  color: white;
}

/* Reset for race newspaper content inside WordPress */
.race-newspaper-content {
  /* Allow the newspaper's own styling to take precedence */
}

.race-newspaper-content .newspaper {
  max-width: 900px;
  margin: 0 auto;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .logo-text h1,
  .logo-text .site-title { font-size: 22px; }
  .month-grid { grid-template-columns: 1fr; }
  .upcoming-races { grid-template-columns: 1fr; }
  .shinbun-sections { grid-template-columns: 1fr; }
  .legend { display: none; }
  .modal { border-radius: 16px 16px 0 0; }
}

.month-anchor { scroll-margin-top: 70px; }
