/* Hover summary popup */
.summary-popup {
  position: absolute;
  width: 400px;
  /* height will auto-grow; max-height constrains */
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  background: #fffbe6; /* very light yellow */
  color: #000;
  border: 1px solid #0000002c;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 12px;
  z-index: 2000;
  pointer-events: auto; /* allow scroll and interaction */
  border-radius: 10px;
}
.summary-popup p {
  font-size: 1.1rem;
  line-height: 1.5;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Georgia, "Times New Roman", Times, serif;
  background: #fff;
  color: #000;
  line-height: 1.4;
  letter-spacing: 0.3px;
  position: relative;
}

/* Top navigation */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 38px;
  background: rgba(255, 255, 255, 0.65);
  color: #000;
  z-index: 2500;
  display: flex;
  align-items: center;
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}
.top-nav .nav-content {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 20px;
  justify-content: center;
}
.top-nav .nav-link {
  color: #000;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.3px;
  padding: 6px 8px;
  border-bottom: 2px solid transparent;
}
.top-nav .nav-link:hover,
.top-nav .nav-link.active {
  border-bottom-color: #000;
}

/* Loading state */
body.is-loading #refreshButton {
  opacity: 0.7;
  cursor: wait;
}

.skeleton {
  position: relative;
  background: #eee;
  overflow: hidden;
  border-radius: 6px;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.6) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: translateX(-100%);
  animation: shimmer 1.2s infinite;
}
.skeleton-image {
  height: 140px;
  margin: 8px 0 12px 0;
  border: 1px solid #00000010;
}
.skeleton-title {
  height: 20px;
  margin: 6px 0;
}
.skeleton-line {
  height: 14px;
  margin: 6px 0;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.error-message {
  color: #a00;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: var(--hero-bg-image, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.15;
  z-index: -1;
  pointer-events: none;
}
/* Hidden background helper class */
body.hide-hero-bg::before {
  display: none;
}

/* 
 removed */

.container {
  max-width: 1200px;
  margin: 0 auto 0;
  padding: 56px 20px 20px 20px; /* top space for slimmer fixed nav */
}

/* Toast notifications */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 10px 14px;
  font-size: 14px;
  z-index: 4000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show {
  opacity: 0.95;
  transform: translateX(-50%) translateY(-4px);
}
.toast.error {
  background: #b00020;
}
.toast.info {
  background: #111;
}

header {
  text-align: center;
  margin-bottom: 15px;
  padding-top: 8px;
  padding-bottom: 20px;
  border-bottom: none;
}

.hero-section {
  text-align: center;
  margin-bottom: 30px;
}

.logo-image {
  max-width: 500px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto 15px auto;
  object-fit: contain;
  aspect-ratio: auto !important;
  border: none;
}

.main-image {
  max-width: 100%;
  margin: 30px 0 20px 0;
  text-align: center;
}

/* When hero comment is hidden, add more spacing above the hero image */
body.no-hero-comment .main-image {
  margin-top: 60px;
}

.main-image img {
  width: min(350px, 100%);
  aspect-ratio: 1 / 1; /* square */
  height: auto;
  object-fit: cover;
  border: 1px solid #0000002b;
  display: inline-block;
  margin: 0 auto;
}

/* Hero skeleton placeholder matches image size */
.hero-skeleton {
  width: min(350px, 100%);
  aspect-ratio: 1 / 1;
  display: none;
  margin: 0 auto 0 auto;
  border: 1px solid #0000002b;
}

.main-image-link {
  color: inherit;
  text-decoration: none;
  font-size: inherit;
  font-weight: inherit;
}

.main-image-link:hover {
  text-decoration: underline;
}

.main-image-title {
  font-size: clamp(1.5rem, 2.5vw + 1rem, 2.2rem);
  font-weight: bold;
  text-align: center;
  margin-top: 16px;
  margin-bottom: 16px;
  letter-spacing: 1px;
  line-height: 1.2;
  line-clamp: 4;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
}

.main-image-comment {
  font-size: 0.95rem;
  color: #444;
  text-align: center;
  margin-top: 30px;
  margin-bottom: 40px;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 30px;
  margin-bottom: 30px;
  overflow-x: hidden;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-width: 0; /* prevent flex children from pushing layout */
}

.news-item {
  margin-bottom: 15px;
  padding: 4px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  overflow-wrap: anywhere;
}

.news-item:last-child {
  border-bottom: none;
}

/* Hide unused placeholders so they don't add vertical gaps */
.news-item:empty {
  display: none;
}

.news-image {
  width: min(100%, 360px);
  height: 200px; /* enforce uniform height for all column images */
  object-fit: cover;
  border: 1px solid #0000002b;
  display: block;
  margin: 8px 0 12px 0; /* left-align within column */
}

.headline {
  display: block;
  font-size: 1.1rem;
  font-weight: bold;
  text-decoration: none;
  color: #000;
  margin-bottom: 2px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.meta {
  margin: 2px 0 6px 0;
}
.meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}
.meta .summary-hint {
  margin-left: 10px;
  flex: 0 0 auto; /* prevent stretching */
}
.meta .source-date {
  flex: 0 1 auto; /* keep button right after label */
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}
.source-date {
  font-size: 0.85rem;
  color: #555;
}

.headline.important {
  text-decoration: none;
}
.headline.very-important {
  text-decoration: underline;
}

.headline.ultra-breaking {
  color: #ff0000;
  text-decoration: none;
}

.headline:hover {
  opacity: 0.8;
}

.headline-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.25);
  background: #fffef6;
  color: #000;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.summary-hint:hover,
.summary-hint:focus {
  opacity: 1;
  background: #fff6cc;
  outline: none;
}

.news-item:hover .summary-hint,
.meta:hover .summary-hint,
.headline-row:hover .summary-hint {
  opacity: 1;
}

.main-image-title .headline-row {
  display: inline-flex;
}

.summary {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

footer {
  text-align: center;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.last-updated {
  font-size: 0.9rem;
  color: #666;
  font-family: "Courier New", Courier, monospace;
  margin-bottom: 5px;
}
.summary-toggle {
  font-size: 0.95rem;
}
/* iOS-style toggle layout */
.ios-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 10px 0;
}
.ios-toggle .label-text {
  flex: 1 1 auto;
}
.ios-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.ios-toggle .ios-switch {
  position: relative;
  width: 48px;
  height: 28px;
  background: #d6d6da;
  border-radius: 999px;
  transition: background 0.25s ease;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.ios-toggle .ios-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.25s ease;
}
.ios-toggle input[type="checkbox"]:checked + .ios-switch {
  background: #34c759; /* iOS green */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}
.ios-toggle input[type="checkbox"]:checked + .ios-switch::after {
  transform: translateX(20px);
}

#refreshButton {
  background: #000;
  color: #fff;
  border: none;
  padding: 10px 14px;
  font-family: "Courier New", Courier, monospace;
  font-size: 18px;
  cursor: pointer;
  text-transform: none;
  font-weight: bold;
  width: fit-content;
  margin: 0 auto;
  border-radius: 5px; /* rounded corners */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.2s ease, transform 0.1s ease, opacity 0.2s ease;
}

#refreshButton:hover {
  background-color: #222;
}

/* Optional: spin icon while loading */
body.is-loading #refreshButton svg {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 768px) {
  .top-nav {
    height: 36px;
  }
  .top-nav .nav-content {
    gap: 18px;
    padding: 0 14px;
    flex-wrap: nowrap;
  }
  .top-nav .nav-link {
    font-size: 0.95rem;
    padding: 4px 8px;
    letter-spacing: 0.3px;
  }
  .news-grid {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .container {
    padding: 46px 18px 18px 18px; /* keep space for fixed nav */
  }

  h1 {
    font-size: 36px;
  }

  .main-image {
    margin: 20px 0; /* bigger spacing on small screens */
    padding: 12px; /* bigger padding on hero image */
  }

  /* fluid sizing already applied via clamp; keep a lower floor on small tablets */
  .main-image-title {
    font-size: clamp(
      1.6rem,
      4vw + 0.8rem,
      2rem
    ); /* bigger fonts for titles on mobile */
    -webkit-line-clamp: 5;
    line-clamp: 5;
  }

  .headline {
    font-size: 1.25rem; /* bigger headlines on mobile */
  }

  .news-item {
    padding: 10px;
  }

  /* removed featured mobile adjustments */

  .news-image {
    height: 230px;
    max-width: 100%;
  }

  #refreshButton {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .top-nav {
    height: 36px;
  }
  .top-nav .nav-content {
    gap: 16px;
    padding: 0 10px;
  }
  .top-nav .nav-link {
    font-size: 1rem;
    padding: 3px 5px;
    letter-spacing: 0.3px;
  }
  .main-image-title {
    font-size: clamp(1.1rem, 5vw + 0.3rem, 1.6rem);
    -webkit-line-clamp: 5;
    line-clamp: 5;
  }
  .headline {
    font-size: 1.35rem;
  }
  .news-image {
    height: 220px;
    max-width: 100%;
  }

  #refreshButton {
    font-size: 18px;
  }

  .container {
    padding: 56px 10px 18px 10px; /* keep space for fixed nav */
  }
}

/* Wider screens: increase spacing and limit column width for better readability */
@media (min-width: 1200px) {
  .container {
    max-width: 1600px;
  }
  .news-grid {
    grid-template-columns: repeat(3, minmax(320px, 420px));
    justify-content: center;
    column-gap: 50px;
    row-gap: 30px;
  }
  .top-nav .nav-content {
    max-width: 1600px;
  }
}

@media (min-width: 1600px) {
  .container {
    max-width: 1800px;
  }
  .news-grid {
    column-gap: 70px;
  }
  .top-nav .nav-content {
    max-width: 1800px;
  }
}

.quote-section {
  text-align: center;
  margin: 40px 0 20px 0;
  padding: 20px;
  border-top: 1px solid #00000044;
  border-bottom: 1px solid #00000044;
}

.quote-section h2 {
  font-size: 20px;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.quote-section blockquote {
  font-size: 0.9rem;
  font-style: italic;
  margin: 0 0 4px 0;
  color: #333;
}

.quote-section cite {
  font-size: 0.9rem;
  color: #666;
  font-style: normal;
  font-weight: bold;
}

/* Settings button */
.settings-button {
  background: transparent;
  border: none;
  color: #000;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: normal;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto;
}
.settings-button:hover {
  text-decoration: underline;
}

/* X link - same styling as settings button */
.x-link {
  background: transparent;
  border: none;
  color: #000;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: normal;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto;
  text-decoration: none;
  font-family: inherit;
  line-height: inherit;
  padding: 0;
  vertical-align: baseline;
}
.x-link:hover {
  text-decoration: underline;
}

/* Button row for Settings and X link */
.button-row {
  display: flex;
  flex-direction: row;
  gap: 30px;
  justify-content: center;
  align-items: center;
}

/* removed unused .settings-icon */

/* Modal */
/* Centered modal with dim backdrop */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

/* Center hero meta under the title and tighten spacing */
#mainHeroMeta {
  display: flex;
  justify-content: center;
  text-align: center;
  margin-top: -5px;
}
.main-image-title {
  margin-bottom: 10px;
}
.modal[aria-hidden="false"] {
  display: flex;
}
.modal-content {
  position: relative;
  background: #fff;
  color: #000;
  border: 1px solid #0000001a;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  border-radius: 14px;
  padding: 16px 16px 8px 16px;
  width: min(350px, 92vw);
  transform-origin: top center;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 160ms ease, transform 160ms ease;
}
.modal[aria-hidden="false"] .modal-content {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.modal-content h3 {
  margin: 4px 0 8px 0;
  text-align: left;
  text-transform: none;
  letter-spacing: 0.2px;
  font-size: 1rem;
  font-weight: 700;
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

/* ===== Dark mode overrides ===== */
html.dark body {
  background: #0f1115;
  color: rgba(255, 255, 119, 0.8);
}

html.dark body::before {
  opacity: 0.07;
}

html.dark .top-nav {
  background: rgba(20, 22, 28, 0.7);
  color: #e6e6e6;
}
html.dark .top-nav .nav-link {
  color: #e6e6e6;
}
html.dark .top-nav .nav-link:hover,
html.dark .top-nav .nav-link.active {
  border-bottom-color: #e6e6e6;
}

html.dark .skeleton {
  background: #1b1f2a;
}
html.dark .skeleton::after {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0) 100%
  );
}

html.dark .main-image img {
  border-color: #ffffff22;
}
html.dark .hero-skeleton {
  border-color: #ffffff22;
}

html.dark .main-image-title a {
  color: #f8ff7a;
}
html.dark .main-image-comment {
  color: #88ff96;
}

html.dark .news-item {
  border-bottom-color: rgba(255, 255, 255, 0.12);
}
html.dark .news-image {
  border-color: #ffffff22;
}
html.dark .headline {
  color: #faffa3;
}
html.dark .source-date {
  color: #9aa4b2;
}

html.dark .summary-hint {
  border-color: rgba(255, 255, 255, 0.25);
  background: #1a1d24;
  color: #e6e6e6;
}
html.dark .summary-hint:hover,
html.dark .summary-hint:focus {
  background: #2a2f3a;
}

html.dark .toast {
  background: #0b0d12;
  color: #e6e6e6;
}

html.dark .quote-section {
  border-color: #ffffff1c;
}
html.dark .quote-section blockquote {
  color: #90bdfc;
}
html.dark .quote-section cite {
  color: #90bdfc;
}

html.dark .settings-button {
  color: #e6e6e6;
}
html.dark .x-link {
  color: #e6e6e6;
}

html.dark .modal-content {
  background: #151922;
  color: #e6e6e6;
  border-color: #ffffff1a;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}
