/* ============ Design tokens ============ */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
  --transition: 0.25s ease;
  --container-max: 1100px;
}

[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1a1d21;
  --text-muted: #5c6470;
  --accent: #0b6bcb;
  --accent-contrast: #ffffff;
  --border: #e2e6ea;
  --shadow: 0 2px 8px rgba(20, 30, 40, 0.08);
}

[data-theme="dark"] {
  --bg: #12151a;
  --surface: #1c2128;
  --text: #e8eaed;
  --text-muted: #9aa4b0;
  --accent: #4da3ff;
  --accent-contrast: #0e1117;
  --border: #2c333c;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ============ Base ============ */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

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

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

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1rem;
}

/* ============ Layout (sidebar + content) ============ */
.layout {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  padding-block: 2rem;
}

.sidebar {
  flex-shrink: 0;
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: sticky;
  top: 1.5rem;
  transition: width var(--transition);
}

.sidebar.is-collapsed {
  width: 3.5rem;
}

.sidebar__toggle {
  align-self: flex-end;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 2.2rem;
  height: 2.2rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color var(--transition);
}

.sidebar__toggle:hover {
  border-color: var(--accent);
}

.sidebar__toggle-icon::before {
  content: "«";
  font-size: 1.1rem;
  color: var(--text);
}

.sidebar.is-collapsed .sidebar__toggle-icon::before {
  content: "»";
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar__link-icon {
  flex-shrink: 0;
  font-size: 1.1rem;
}

.sidebar.is-collapsed .sidebar__link {
  padding-inline: 0;
  justify-content: center;
}

.sidebar.is-collapsed .sidebar__link-text {
  display: none;
}

.sidebar__link:hover {
  background: var(--surface);
}

.sidebar__link.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
}

.content {
  flex: 1;
  min-width: 0;
}

@media (max-width: 700px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    position: static;
    width: 100% !important;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar__toggle {
    display: none;
  }

  .sidebar.is-collapsed .sidebar__link {
    padding-inline: 1rem;
    justify-content: flex-start;
  }

  .sidebar.is-collapsed .sidebar__link-text {
    display: inline;
  }
}

/* ============ Header (banner) ============ */
.topbar {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0.85rem 1rem 0;
  display: flex;
  justify-content: flex-end;
  position: relative;
  z-index: 3;
}

.site-header {
  background: url('../img/banner.jpg') center center / cover no-repeat;
  border-bottom: 1px solid var(--border);
  position: relative;
  width: min(100%, 1100px);
  margin: 0 auto;
  min-height: 0;
  height: auto;
  aspect-ratio: 4128 / 1024;
  overflow: hidden;
  border-radius: 0 0 18px 18px;
}

.header-inner {
  width: 100%;
  min-height: 0;
  padding: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text);
}

.brand__logo {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.brand__title {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 700;
}

/* Botón de tema (claro/oscuro) */
.theme-toggle {
  position: relative;
  top: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  width: 2.7rem;
  height: 2.7rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(2px);
  z-index: 1;
}

.theme-toggle::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  z-index: -1;
}

.theme-toggle:hover {
  border-color: rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
}

.theme-toggle__icon::before {
  content: "🌙";
  font-size: 1.1rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

[data-theme="dark"] .theme-toggle {
  background: rgba(15, 23, 42, 0.28);
  border-color: rgba(255, 255, 255, 0.7);
}

[data-theme="dark"] .theme-toggle__icon::before {
  content: "☀️";
}

/* ============ Post grid ============ */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  padding-block: 2rem;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), box-shadow var(--transition);
}

.post-card:hover {
  transform: translateY(-4px);
}

.post-card__image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.post-card__body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.post-card__title {
  margin: 0;
  font-size: 1.15rem;
}

.post-card__title a {
  color: var(--text);
}

.post-card__title a:hover {
  color: var(--accent);
}

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

.post-card__summary {
  margin: 0;
  color: var(--text-muted);
  flex: 1;
}

.post-card__link {
  font-weight: 600;
  font-size: 0.9rem;
}

/* ============ Post detail ============ */
.post-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-block: 2rem;
  padding: 2rem;
  max-width: 800px;
  margin-inline: auto;
}

.post-detail__image {
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  background: var(--bg);
  display: block;
}

.post-detail__title {
  margin: 0 0 0.5rem;
  font-size: 1.8rem;
  line-height: 1.3;
}

.post-detail__meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.post-detail__content p {
  margin-block: 0 1rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-weight: 600;
}

/* ============ States ============ */
.state-message {
  text-align: center;
  padding-block: 4rem;
  color: var(--text-muted);
}

/* ============ Footer ============ */
.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ============ Responsive ============ */
@media (max-width: 600px) {
  .post-detail {
    padding: 1.25rem;
  }

  .post-detail__title {
    font-size: 1.4rem;
  }
}
