/* ============================================
   Lewis's Homepage — Styles
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #F1EFE9;
  --card-bg: #FFFFFF;
  --primary: #1D4ED8;
  --primary-hover: #1E40AF;
  --primary-light: #DBEAFE;
  --green: #16A34A;
  --green-bg: #DCFCE7;
  --red: #DC2626;
  --red-bg: #FEE2E2;
  --text: #1F2937;
  --text-muted: #6B7280;
  --text-light: #9CA3AF;
  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 320px;
  --font-ui: 'Outfit', sans-serif;
  --font-headline: 'Lora', serif;
  --sidebar-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --touch-min: 44px;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Sidebar --- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 20px;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.sidebar-section {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-section-title svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

/* --- Weather Widget --- */
.weather-current {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.weather-temp {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.weather-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.weather-condition {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.weather-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.weather-forecast {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.forecast-day {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
}

.forecast-day-name {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.forecast-icon {
  font-size: 1.1rem;
  margin-bottom: 2px;
}

.forecast-temps {
  font-size: 0.7rem;
  color: var(--text);
}

.forecast-temps .low {
  color: var(--text-muted);
}

.weather-loading,
.weather-error {
  text-align: center;
  padding: 16px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Calendar Widget --- */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.calendar-month {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.calendar-nav {
  display: flex;
  gap: 4px;
}

.calendar-nav button {
  background: var(--card-bg);
  border: none;
  border-radius: 6px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: background 0.15s, color 0.15s;
}

.calendar-nav button:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.calendar-grid .day-header {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 4px 0;
}

.calendar-grid .day {
  font-size: 0.75rem;
  padding: 5px 0;
  border-radius: 6px;
  cursor: default;
  color: var(--text-muted);
  transition: background 0.15s;
}

.calendar-grid .day.current-month {
  color: var(--text);
}

.calendar-grid .day.today {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.calendar-grid .day.empty {
  visibility: hidden;
}

/* --- Quick Links --- */
.quick-links-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quick-links-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.quick-links-list a:hover {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}

.quick-link-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* --- Main Content --- */
.content {
  padding: 24px 32px;
  min-height: 100vh;
}

/* --- Header --- */
.header {
  margin-bottom: 24px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.greeting {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.greeting-text {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}

.greeting-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill.open {
  background: var(--green-bg);
  color: var(--green);
}

.status-pill.closed {
  background: var(--red-bg);
  color: var(--red);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.search-bar {
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar input::placeholder {
  color: var(--text-light);
}

.search-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.search-icon svg {
  width: 18px;
  height: 18px;
}

/* --- Feed Tabs --- */
.feed-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.feed-tab {
  padding: 10px 16px;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.feed-tab:hover {
  color: var(--text);
}

.feed-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* --- News Grid --- */
.news-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.news-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.news-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  text-decoration: none;
  color: inherit;
}

.news-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.news-source {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.news-source.foxnews {
  background: #1a2a4a;
  color: #fff;
}

.news-source.cnn {
  background: #CC0000;
  color: #fff;
}

.news-source.southflorida {
  background: #0E9AA7;
  color: #fff;
}

.news-source.techcrunch {
  background: #00A562;
  color: #fff;
}

.news-source.ainews {
  background: #D97706;
  color: #fff;
}

.news-source.reddit {
  background: #FF4500;
  color: #fff;
}

.news-time {
  font-size: 0.72rem;
  color: var(--text-light);
  white-space: nowrap;
}

.news-title {
  font-family: var(--font-headline);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

.news-excerpt {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Loading & Empty States --- */
.news-loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.news-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

.news-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* --- Skeleton Loading Cards --- */
.skeleton-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-line {
  height: 12px;
  background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.long { width: 100%; }
.skeleton-line.title { height: 16px; width: 90%; }

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

/* --- Scrollbar --- */
.content::-webkit-scrollbar {
  width: 6px;
}

.content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* --- Article Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-reader {
  position: relative;
  width: 640px;
  max-width: 90vw;
  max-height: 85vh;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.2s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.modal-overlay.active .modal-reader {
  transform: scale(1) translateY(0);
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  z-index: 1;
}

.modal-close-btn:hover {
  background: var(--red-bg);
  color: var(--red);
}

.modal-close-btn svg {
  width: 18px;
  height: 18px;
}

.modal-body {
  padding: 32px 32px 28px;
}

.modal-body .news-source {
  display: inline-block;
  margin-bottom: 12px;
}

.modal-time {
  display: block;
  font-size: 0.78rem;
  color: var(--text-light);
  margin-bottom: 16px;
}

.modal-headline {
  font-family: var(--font-headline);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 16px;
}

.modal-excerpt {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.modal-excerpt p {
  margin-bottom: 12px;
}

.modal-excerpt p:last-child {
  margin-bottom: 0;
}

.modal-hero-img {
  width: calc(100% + 64px);
  margin: -32px -32px 20px -32px;
  max-height: 360px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-inline-img {
  width: 100%;
  border-radius: var(--radius-sm);
  margin: 8px 0 16px;
  display: block;
  max-height: 400px;
  object-fit: cover;
}

.modal-author {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.modal-read-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}

.modal-read-btn:hover {
  background: var(--primary-hover);
  text-decoration: none;
  color: #fff;
}

.modal-read-btn svg {
  width: 16px;
  height: 16px;
}

.modal-fallback-note {
  font-size: 0.82rem;
  font-style: italic;
  color: var(--text-light);
  margin-bottom: 12px;
}

/* --- Hamburger Toggle (hidden on desktop) --- */
.sidebar-toggle {
  display: none;
}

/* --- Sidebar Backdrop (hidden on desktop) --- */
.sidebar-backdrop {
  display: none;
}

/* --- Utility --- */
.hidden {
  display: none !important;
}

/* ============================================
   Mobile — iPhone 16 Pro Max & all phones
   ============================================ */
@media (max-width: 768px) {

  /* --- Safe area insets for notch & home indicator --- */
  body {
    display: flex;
    flex-direction: column;
    grid-template-columns: unset;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  /* --- Hamburger button --- */
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: calc(env(safe-area-inset-top) + 12px);
    left: 12px;
    z-index: 1001;
    width: var(--touch-min);
    height: var(--touch-min);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    cursor: pointer;
    color: var(--text);
    padding: 0;
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar-toggle svg {
    width: 22px;
    height: 22px;
  }

  /* --- Sidebar: off-screen overlay panel --- */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 85vw);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform var(--sidebar-transition);
    border-right: 1px solid var(--border);
    padding-top: calc(env(safe-area-inset-top) + 24px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 24px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* --- Sidebar backdrop --- */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--sidebar-transition), visibility var(--sidebar-transition);
    -webkit-tap-highlight-color: transparent;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }

  /* --- Body scroll lock when sidebar open --- */
  body.sidebar-open {
    overflow: hidden;
  }

  /* --- Main content: full-width, adjusted padding --- */
  .content {
    padding: 16px;
    padding-top: calc(env(safe-area-inset-top) + 12px + var(--touch-min) + 12px);
    min-height: 100vh;
    width: 100%;
  }

  /* --- Header adjustments --- */
  .header-top {
    flex-wrap: wrap;
    gap: 8px;
  }

  .greeting-text {
    font-size: 1.3rem;
  }

  .search-bar input {
    padding: 14px 16px 14px 44px;
    font-size: 16px;
  }

  /* --- Feed tabs: touch-friendly --- */
  .feed-tab {
    padding: 12px 16px;
    font-size: 0.85rem;
    min-height: var(--touch-min);
  }

  /* --- News grid: single column --- */
  .news-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* --- News card: disable hover lift on touch --- */
  .news-card {
    padding: 16px;
  }

  .news-card:hover {
    transform: none;
  }

  /* --- Article modal: full-screen --- */
  .modal-overlay {
    align-items: stretch;
  }

  .modal-reader {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  .modal-body {
    padding: 20px 16px calc(env(safe-area-inset-bottom) + 20px);
  }

  .modal-close-btn {
    top: calc(env(safe-area-inset-top) + 10px);
    right: 10px;
    width: var(--touch-min);
    height: var(--touch-min);
  }

  .modal-close-btn svg {
    width: 22px;
    height: 22px;
  }

  .modal-headline {
    font-size: 1.25rem;
  }

  .modal-hero-img {
    width: calc(100% + 32px);
    margin: -20px -16px 16px -16px;
    border-radius: 0;
  }

  .modal-read-btn {
    min-height: var(--touch-min);
    padding: 12px 24px;
    font-size: 0.95rem;
  }

  /* --- Quick links: touch-sized --- */
  .quick-links-list a {
    padding: 12px 10px;
    min-height: var(--touch-min);
  }

  /* --- Calendar nav buttons: touch-sized --- */
  .calendar-nav button {
    width: var(--touch-min);
    height: 36px;
    font-size: 0.85rem;
  }

  /* --- Status pill for narrow screens --- */
  .status-pill {
    font-size: 0.75rem;
    padding: 5px 10px;
  }
}
