/* ============================================
   Spencer's Portugal Guide — Design System
   Typefaces: Fraunces (serif) + IBM Plex Mono
   ============================================ */

/* --- Reset & Base --- */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-weight: 300;
  font-optical-sizing: auto;
  line-height: 1.65;
  color: #191919;
  background-color: #F8F8F6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

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

a:hover {
  opacity: 0.7;
}

/* --- Utility: Mono (metadata) --- */

.mono {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.5;
}

/* --- Layout --- */

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container--wide {
  max-width: 960px;
}

main {
  flex: 1;
}

/* --- Section Page Header / Navigation --- */

.site-header {
  padding: 1.5rem 0;
  border-bottom: 1px solid #E0E0DC;
}

.site-header .container {
  max-width: 960px;
}

.header-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.site-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 300;
  font-size: 1.125rem;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.site-title:hover {
  opacity: 0.7;
}

.header-updated {
  color: #888;
}

.site-nav {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.site-nav ul {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  white-space: nowrap;
}

.site-nav a {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border: 1px solid #CFCFC9;
  border-radius: 100px;
  text-decoration: none;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #191919;
  transition: background-color 0.15s, color 0.15s;
}

.site-nav a:hover,
.site-nav a.active {
  background-color: #191919;
  color: #F8F8F6;
  border-color: #191919;
  opacity: 1;
}

/* =============================================
   Homepage
   ============================================= */

.home-masthead-bar {
  padding: 2.5rem 1.5rem 1.5rem;
  text-align: center;
}

.home-masthead {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 900;
  font-size: clamp(3rem, 12vw, 9rem);
  line-height: 0.9;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

/* --- Split Hero (image left, text right) --- */

.home-split {
  display: grid;
  grid-template-columns: 55% 1fr;
  min-height: 520px;
}

.home-split-image {
  position: relative;
  overflow: hidden;
}

.home-split-image img {
  width: 100%;
  height: 100%;
  min-height: 520px;
  object-fit: cover;
  object-position: center 35%;
  transform: scale(1.08);
}

.hero-image-placeholder {
  width: 100%;
  height: 100%;
  min-height: 520px;
  background-color: #E4E3DD;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-split-text {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 2.5rem 3rem 2.5rem 2.5rem;
}

.home-headline {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 300;
  font-size: clamp(1.75rem, 3.5vw, 3rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin-bottom: 1.5rem;
}

.home-updated {
  color: #999;
  margin-bottom: 1.25rem;
}

.home-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.home-nav a {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border: 1px solid #CFCFC9;
  border-radius: 100px;
  text-decoration: none;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #191919;
  transition: background-color 0.15s, color 0.15s;
}

.home-nav a:hover {
  background-color: #191919;
  color: #F8F8F6;
  border-color: #191919;
  opacity: 1;
}

/* --- Homepage Content --- */

.hero {
  padding: 3.5rem 0 4rem;
}

.hero-intro {
  font-size: 1.0625rem;
  line-height: 1.75;
  max-width: 580px;
  color: #444;
}

.hero-intro p + p {
  margin-top: 1rem;
}

/* --- Section Grid (Homepage) --- */

.section-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background-color: #D8D8D2;
}

.section-card {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.75rem 1rem;
  background-color: #F8F8F6;
  text-decoration: none;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 400;
  font-size: 1.125rem;
  line-height: 1.3;
  color: #191919;
  transition: background-color 0.2s;
}

.section-card:hover {
  background-color: #EEEEE8;
  opacity: 1;
}

/* =============================================
   Section Pages
   ============================================= */

.section-header {
  padding: 3.5rem 0 2rem;
  border-bottom: 1px solid #E0E0DC;
}

.section-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 300;
  font-size: 2.5rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
}

.section-updated {
  color: #888;
  margin-bottom: 1.5rem;
}

.section-intro {
  font-size: 1.0625rem;
  line-height: 1.7;
  color: #444;
  max-width: 560px;
  border: 1px dashed #CFCFC9;
  padding: 1.25rem;
  border-radius: 4px;
}

/* --- Entries --- */

.entries {
  padding: 2rem 0 4rem;
}

.entry {
  padding: 2rem 0;
  border-bottom: 1px solid #E0E0DC;
}

.entry:first-child {
  padding-top: 0;
}

.entry:last-child {
  border-bottom: none;
}

.entry-name {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 1.375rem;
  line-height: 1.3;
  margin-bottom: 0.375rem;
}

.entry-meta {
  color: #888;
  margin-bottom: 1rem;
}

.entry-meta span + span::before {
  content: " \00B7 ";
  margin: 0 0.15em;
}

.entry-take {
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 1rem;
  color: #444;
  border: 1px dashed #CFCFC9;
  padding: 1.25rem;
  border-radius: 4px;
}

.entry-notes {
  color: #888;
}

.entry-link {
  margin-top: 0.5rem;
}

.entry-link a {
  color: #191919;
}

/* --- Placeholder Styling --- */

.placeholder-label {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #999;
  line-height: 1.6;
}

/* --- Subsection headings within a page --- */

.subsection-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 300;
  font-size: 1.625rem;
  line-height: 1.25;
  margin-top: 3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #E0E0DC;
}

/* --- Filter Bar --- */

.filter-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #F8F8F6;
  padding: 1.25rem 0 0.75rem;
}

.filter-search {
  width: 100%;
  padding: 0.625rem 0;
  border: none;
  border-bottom: 1px solid #E0E0DC;
  background: transparent;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.0625rem;
  font-weight: 300;
  color: #191919;
  outline: none;
  margin-bottom: 1rem;
}

.filter-search::placeholder {
  color: #BBBBB5;
}

.filter-search:focus {
  border-bottom-color: #191919;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-label {
  color: #999;
  white-space: nowrap;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.filter-pill {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border: 1px solid #CFCFC9;
  border-radius: 100px;
  background: transparent;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #191919;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.filter-pill:hover,
.filter-pill.active {
  background-color: #191919;
  color: #F8F8F6;
  border-color: #191919;
}

.filter-count {
  color: #999;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #E0E0DC;
}

/* --- Interactive Entries (collapsible) --- */

details.entry {
  padding: 0;
}

details.entry summary {
  list-style: none;
  cursor: pointer;
  padding: 1.25rem 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

details.entry summary::-webkit-details-marker {
  display: none;
}

details.entry summary::after {
  content: '+';
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.75rem;
  color: #999;
  flex-shrink: 0;
  transition: color 0.15s;
}

details.entry[open] summary::after {
  content: '\2212';
}

details.entry summary:hover::after {
  color: #191919;
}

.entry-summary {
  min-width: 0;
}

details.entry .entry-name {
  margin-bottom: 0.125rem;
}

.entry-meta-inline {
  color: #888;
}

.entry-meta-inline span + span::before {
  content: " \00B7 ";
  margin: 0 0.1em;
}

details.entry .entry-detail {
  padding: 0 0 1.75rem;
}

details.entry .entry-take {
  border: none;
  padding: 0;
  border-radius: 0;
  margin-bottom: 0.75rem;
}

details.entry .entry-notes {
  margin-bottom: 0.5rem;
}

/* --- View Toggle (List / Map) --- */

.filter-top {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
}

.filter-top .filter-search {
  flex: 1;
}

.view-toggle {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
  padding-bottom: 0.625rem;
}

.view-btn {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border: 1px solid #CFCFC9;
  border-radius: 100px;
  background: transparent;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #191919;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.view-btn:hover,
.view-btn.active {
  background-color: #191919;
  color: #F8F8F6;
  border-color: #191919;
}

/* --- Map --- */

.entries-map {
  height: 500px;
  border-radius: 4px;
  border: 1px solid #E0E0DC;
  margin-top: 0.5rem;
}

.entries-map .leaflet-popup-content-wrapper {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 0.9375rem;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.entries-map .leaflet-popup-content {
  margin: 0.75rem 1rem;
  line-height: 1.4;
}

.entries-map .leaflet-popup-content .popup-name {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.entries-map .leaflet-popup-content .popup-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 0.5rem;
}

.entries-map .leaflet-popup-content .popup-link {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.map-empty-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #999;
}

/* --- Google Maps Link --- */

.maps-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #191919;
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border: 1px solid #CFCFC9;
  border-radius: 100px;
  transition: background-color 0.15s, color 0.15s;
}

.maps-link:hover {
  background-color: #191919;
  color: #F8F8F6;
  border-color: #191919;
  opacity: 1;
}

.maps-icon {
  width: 0.75rem;
  height: 0.75rem;
  flex-shrink: 0;
}

/* --- Favorites Button --- */

.fav-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: #CFCFC9;
  transition: color 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.fav-btn:hover {
  color: #191919;
}

.fav-btn.active {
  color: #D94F4F;
}

.fav-btn svg {
  width: 15px;
  height: 15px;
  display: block;
}

.fav-btn.active svg {
  fill: currentColor;
}

/* --- Entry Actions Row --- */

.entry-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.75rem;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #191919;
  background: none;
  padding: 0.35rem 0.75rem;
  border: 1px solid #CFCFC9;
  border-radius: 100px;
  cursor: pointer;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background-color 0.15s, color 0.15s;
}

.share-btn:hover {
  background-color: #191919;
  color: #F8F8F6;
  border-color: #191919;
}

.share-btn svg {
  width: 0.7rem;
  height: 0.7rem;
  flex-shrink: 0;
}

.entry.hidden,
.subsection-title.hidden {
  display: none;
}

/* --- Footer --- */

.site-footer {
  padding: 2rem 0;
  border-top: 1px solid #E0E0DC;
  text-align: center;
  color: #999;
}

/* =============================================
   Responsive
   ============================================= */

@media (max-width: 600px) {
  .home-masthead-bar {
    padding: 2rem 1.25rem 1rem;
  }

  .home-split {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .hero-image-placeholder {
    min-height: 280px;
    height: 280px;
  }

  .home-split-text {
    padding: 1.5rem 1.25rem 2rem;
  }

  .home-nav a {
    font-size: 0.5625rem;
    padding: 0.3rem 0.65rem;
  }

  .section-grid {
    grid-template-columns: 1fr 1fr;
  }

  .section-card {
    font-size: 0.9375rem;
    padding: 1.25rem 0.75rem;
  }

  .section-title {
    font-size: 2rem;
  }

  .entry-name {
    font-size: 1.1875rem;
  }

  .site-nav a {
    font-size: 0.5625rem;
    padding: 0.3rem 0.6rem;
  }

  .header-top {
    flex-direction: column;
    gap: 0.25rem;
  }

  .filter-top {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .view-toggle {
    align-self: flex-start;
    padding-bottom: 0;
  }

  .filter-row {
    gap: 0.75rem;
  }

  .filter-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.375rem;
  }

  .filter-pill {
    font-size: 0.5625rem;
    padding: 0.25rem 0.6rem;
  }

  details.entry summary {
    padding: 1rem 0;
  }

  .entries-map {
    height: 400px;
  }
}

@media (min-width: 601px) and (max-width: 960px) {
  .section-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
