:root {
  --bg: #eef2f6;
  --text: #1a2a3a;
  --text-secondary: #2e4252;
  --text-muted: #4a6478;
  --card-bg: #e4e8ee;
  --badge-bg: #d8dee6;
  --divider: #ccc;
  --social-border: #999;
  --ocean: #a6c8d9;
}

[data-theme="dark"] {
  --bg: #1a2a3a;
  --text: #eef2f6;
  --text-secondary: #c8d4e0;
  --text-muted: #94a8bc;
  --card-bg: #243848;
  --badge-bg: #2e4858;
  --divider: #3a5468;
  --social-border: #6a8098;
  --ocean: #2e618b;
}

@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: fade-out 0.25s ease-in;
}

::view-transition-new(root) {
  animation: fade-in 0.3s ease-out;
}

@keyframes fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

html {
  scroll-behavior: smooth;
  background-color: var(--ocean);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'EB Garamond', serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100dvh;
}


.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 60px 40px 140px;
  padding-top: max(60px, calc(env(safe-area-inset-top) + 20px));
  padding-left: max(40px, env(safe-area-inset-left));
  padding-right: max(40px, env(safe-area-inset-right));
  position: relative;
  z-index: 2;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 48px;
}

h1 {
  font-family: 'EB Garamond', serif;
  font-weight: 600;
  font-size: 2.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-variant: small-caps;
  display: flex;
  align-items: center;
  gap: 12px;
}

.anchor-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  background: var(--text);
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 18px;
  transition: background 0.3s;
}

.header-anchor {
  width: 34px;
  height: 34px;
}

.header-anchor path,
.header-anchor line,
.header-anchor circle {
  stroke: var(--bg);
  fill: none;
  transition: stroke 0.3s;
}

h1 a {
  color: inherit;
  text-decoration: none;
  display: inline-block;
  position: relative;
  padding-bottom: 14px;
}

h1 a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 540px;
  max-width: 100%;
  height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 540 12'%3E%3Cline x1='0' y1='6' x2='540' y2='6' stroke='%231a2a3a' stroke-width='1.2'/%3E%3Cpath d='M265,6 L270,2 L275,6 L270,10 Z' fill='%231a2a3a'/%3E%3C/svg%3E") no-repeat center;
  background-size: contain;
}

nav {
  display: flex;
  gap: 32px;
}

nav a {
  font-family: 'EB Garamond', serif;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
  transition: border-color 0.2s, color 0.3s;
}

nav a:hover,
nav a.active {
  border-bottom-color: var(--text);
}

body:has(.page-scroll) {
  height: 100dvh;
  overflow: hidden;
}

.page-scroll {
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  z-index: 2;
}

body.home {
  height: 100dvh;
  overflow: hidden;
}

body.home .container {
  padding-top: 40px;
  padding-bottom: 20px;
}

.hero-row {
  display: flex;
  align-items: center;
  gap: 32px;
  margin-bottom: 0;
}

.hero-img {
  width: 45%;
  aspect-ratio: 1 / 1;
  max-height: 50vh;
  object-fit: cover;
  flex-shrink: 0;
  border-radius: 4px;
}

.divider {
  border: none;
  border-top: 1px solid var(--divider);
  margin: 24px 0;
}

.bio {
  font-size: 18px;
  line-height: 1.8;
}

.section-title {
  font-family: 'EB Garamond', serif;
  font-weight: 600;
  font-size: 1.4rem;
  margin-bottom: 24px;
  margin-top: 48px;
}

.section-title:first-of-type {
  margin-top: 0;
}

.entries {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.entry {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.entry .bullet {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  margin-top: 8px;
  background: none;
  position: relative;
}

.entry .bullet::before {
  content: '✦';
  position: absolute;
  top: -2px;
  left: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1;
}

.entry-content {
  background: var(--card-bg);
  border-radius: 4px;
  padding: 20px 24px;
  flex: 1;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
}

.entry-content:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .entry-content:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  gap: 16px;
}

.entry-title {
  font-weight: 500;
  font-size: 15px;
}

.entry-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 8px;
}

.entry-title a {
  color: var(--text);
  text-decoration: none;
}

.entry-title a:hover {
  text-decoration: underline;
}

.entry-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}

.entry-date {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.entry-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.entry-desc .entry-link {
  font-style: italic;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--social-border);
  padding-bottom: 1px;
  margin-left: 4px;
  transition: color 0.2s, border-color 0.2s;
}

.entry-desc .entry-link:hover {
  color: var(--text);
  border-bottom-color: var(--text);
}

.project-entry {
  display: flex;
  align-items: center;
  gap: 24px;
}

.project-main {
  flex: 1;
  min-width: 0;
}

.project-entry .entry-stats {
  margin-top: 0;
  flex-direction: column;
  flex-shrink: 0;
}

.entry-stats {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.entry-stats span {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--badge-bg);
  padding: 3px 10px;
  border-radius: 3px;
  letter-spacing: 0.02em;
}

.socials {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.socials a {
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--social-border);
  padding-bottom: 1px;
  transition: border-color 0.2s, color 0.3s;
}

.socials a:hover {
  border-bottom-color: var(--text);
}

/* --- Content page --- */
.content-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.content-header .section-title {
  margin-bottom: 0;
}

.content-header .entry-desc {
  margin-right: auto;
}

.content-header .entry-desc a {
  color: var(--text);
}

.content-header .filters {
  margin-bottom: 0;
}

.filters {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
}

.filter-btn {
  font-family: 'EB Garamond', serif;
  font-size: 14px;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 8px 0 2px;
  cursor: pointer;
  border-bottom: 1.5px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.filter-btn:hover {
  color: var(--text);
}

.filter-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.entry[data-hidden="true"],
.entry[data-collapsed="true"] {
  display: none;
}

.see-more-btn {
  font-family: 'EB Garamond', serif;
  font-size: 14px;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 16px 0 2px;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.see-more-btn:hover {
  color: var(--text);
}

.publisher-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
}

.publisher-badge[data-pub="a16z"] {
  background: #dce8d4;
  color: #3a5a2a;
}

.publisher-badge[data-pub="substack"] {
  background: #d4dce8;
  color: #2a3a5a;
}

.publisher-badge[data-pub="palladium"] {
  background: #e8d4dc;
  color: #5a2a3a;
}

.publisher-badge[data-pub="pirate-wires"] {
  background: #e8e0d4;
  color: #5a4a2a;
}

[data-theme="dark"] .publisher-badge[data-pub="a16z"] {
  background: #2a3a28;
  color: #a8c8a0;
}

[data-theme="dark"] .publisher-badge[data-pub="substack"] {
  background: #28303a;
  color: #a0b0c8;
}

[data-theme="dark"] .publisher-badge[data-pub="palladium"] {
  background: #3a2830;
  color: #c8a0b0;
}

[data-theme="dark"] .publisher-badge[data-pub="pirate-wires"] {
  background: #3a3428;
  color: #c8b8a0;
}


/* --- Dark mode toggle --- */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 28px;
  width: 44px;
  height: 44px;
  border: none;
  background: var(--card-bg);
  cursor: pointer;
  font-size: 24px;
  line-height: 44px;
  text-align: center;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: background 0.3s, box-shadow 0.3s, transform 0.2s;
  z-index: 3;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .theme-toggle {
  box-shadow: 0 0 12px rgba(200, 180, 100, 0.3);
}

[data-theme="dark"] .theme-toggle:hover {
  box-shadow: 0 0 18px rgba(200, 180, 100, 0.4);
}

/* --- Sky canvases (stars & clouds) --- */
.stars,
.clouds {
  position: fixed;
  inset: -60px;
  width: calc(100% + 120px);
  height: calc(100dvh + 120px);
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.5s ease;
}

.stars { opacity: 0; }
.clouds { opacity: 1; }

[data-theme="dark"] .stars { opacity: 1; }
[data-theme="dark"] .clouds { opacity: 0; }

[data-theme="dark"] h1 a::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 540 12'%3E%3Cline x1='0' y1='6' x2='540' y2='6' stroke='%23eef2f6' stroke-width='1.2'/%3E%3Cpath d='M265,6 L270,2 L275,6 L270,10 Z' fill='%23eef2f6'/%3E%3C/svg%3E");
}

/* --- Ocean waves --- */
.ocean {
  position: fixed;
  bottom: -60px;
  left: 0;
  width: 100%;
  height: calc(260px + 60px + env(safe-area-inset-bottom));
  overflow: hidden;
  pointer-events: none;
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom);
  background: linear-gradient(to bottom, transparent 35%, var(--ocean) 60%);
}

.wave {
  position: absolute;
  bottom: env(safe-area-inset-bottom);
  left: -100%;
  width: 300%;
  height: calc(100% - env(safe-area-inset-bottom));
  background-repeat: repeat-x;
  background-size: 600px 200px;
  background-position: bottom;
}

.wave--1 {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 200'%3E%3Cpath d='M0,75 C50,50 100,100 150,65 C200,30 250,100 300,70 C350,40 400,105 450,70 C500,35 550,95 600,75 L600,200 L0,200 Z' fill='%23507090' opacity='0.6'/%3E%3C/svg%3E");
  animation: wave-drift 8s ease-in-out infinite alternate;
}

.wave--2 {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 200'%3E%3Cpath d='M0,85 C50,65 100,113 150,87 C200,61 250,113 300,90 C350,67 400,113 450,93 C500,73 550,105 600,85 L600,200 L0,200 Z' fill='%2380b0c8' opacity='0.5'/%3E%3C/svg%3E");
  animation: wave-drift 10s ease-in-out infinite alternate-reverse;
  animation-delay: -2s;
}

.wave--3 {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 200'%3E%3Cpath d='M0,105 C50,87 100,123 150,103 C200,83 250,123 300,107 C350,91 400,123 450,107 C500,91 550,120 600,105 L600,200 L0,200 Z' fill='%23a8d0e0' opacity='0.45'/%3E%3C/svg%3E");
  animation: wave-drift 12s ease-in-out infinite alternate;
  animation-delay: -4s;
}

.wave--4 {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 200'%3E%3Cpath d='M0,132 C50,124 100,142 150,130 C200,118 250,142 300,134 C350,126 400,142 450,134 C500,126 550,140 600,132 L600,200 L0,200 Z' fill='%23c8e4f0' opacity='0.4'/%3E%3C/svg%3E");
  animation: wave-drift 14s ease-in-out infinite alternate-reverse;
  animation-delay: -6s;
}

@keyframes wave-drift {
  from { transform: translateX(0); }
  to   { transform: translateX(200px); }
}

[data-theme="dark"] .wave--1 {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 200'%3E%3Cpath d='M0,75 C50,50 100,100 150,65 C200,30 250,100 300,70 C350,40 400,105 450,70 C500,35 550,95 600,75 L600,200 L0,200 Z' fill='%230a1828' opacity='0.85'/%3E%3C/svg%3E");
}
[data-theme="dark"] .wave--2 {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 200'%3E%3Cpath d='M0,85 C50,65 100,113 150,87 C200,61 250,113 300,90 C350,67 400,113 450,93 C500,73 550,105 600,85 L600,200 L0,200 Z' fill='%23183858' opacity='0.75'/%3E%3C/svg%3E");
}
[data-theme="dark"] .wave--3 {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 200'%3E%3Cpath d='M0,105 C50,87 100,123 150,103 C200,83 250,123 300,107 C350,91 400,123 450,107 C500,91 550,120 600,105 L600,200 L0,200 Z' fill='%23285880' opacity='0.65'/%3E%3C/svg%3E");
}
[data-theme="dark"] .wave--4 {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 200'%3E%3Cpath d='M0,132 C50,124 100,142 150,130 C200,118 250,142 300,134 C350,126 400,142 450,134 C500,126 550,140 600,132 L600,200 L0,200 Z' fill='%233a78a8' opacity='0.5'/%3E%3C/svg%3E");
}

@media (prefers-reduced-motion: reduce) {
  .wave {
    animation: none !important;
  }
}

/* Tablet - stack hero layout */
@media (max-width: 1024px) {
  .hero-row {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }

  .hero-text {
    text-align: center;
  }

  .socials {
    justify-content: center;
  }

  .hero-img {
    width: 60%;
    max-height: 35vh;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 48px 28px 160px;
  }

  header {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
  }

  h1 {
    font-size: 2rem;
    letter-spacing: 0.14em;
  }

  h1 a::after {
    width: calc(100vw - 56px);
  }

  nav {
    gap: 24px;
  }

  .hero-row {
    flex-direction: column;
    gap: 12px;
  }

  .hero-img {
    width: 70%;
    aspect-ratio: 1 / 1;
    max-height: 30vh;
  }

  .entries {
    margin-left: -28px;
    margin-right: -28px;
  }

  .entry {
    padding-left: 28px;
    padding-right: 28px;
  }

  body.home {
    min-height: 100dvh;
    height: auto;
    overflow: auto;
  }

  .theme-toggle {
    position: absolute;
    top: 112px;
    right: 28px;
  }

  .entry-header {
    flex-direction: column;
    gap: 4px;
  }

  .entry-date {
    font-size: 11px;
  }

  .project-entry {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .project-entry .entry-stats {
    flex-direction: row;
  }

  .entry-title {
    font-size: 14px;
  }

  .stars,
  .clouds {
    position: fixed;
  }

  .ocean {
    height: calc(200px + 60px + env(safe-area-inset-bottom));
  }

}

/* Mobile */
@media (max-width: 480px) {
  .container {
    padding: 32px 16px 140px;
  }

  h1 {
    font-size: 1.6rem;
    letter-spacing: 0.12em;
  }

  nav {
    gap: 20px;
  }

  nav a {
    font-size: 13px;
  }

  .bio {
    font-size: 14px;
  }

  .entry-content {
    padding: 14px 16px;
  }

  .entry .bullet {
    width: 8px;
    height: 8px;
    margin-top: 6px;
  }

  .entries {
    margin-left: -16px;
    margin-right: -16px;
  }

  .entry {
    gap: 12px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .entry-title {
    font-size: 12px;
  }

  .entry-desc {
    font-size: 12px;
  }

  .entry-date {
    font-size: 11px;
  }

  .entry-stats {
    gap: 10px;
  }

  .entry-stats span {
    font-size: 11px;
  }

  .socials {
    gap: 16px;
  }

  .socials a {
    font-size: 13px;
  }

  .section-title {
    font-size: 1.2rem;
    margin-top: 32px;
  }

  .ocean {
    height: calc(260px + 60px + env(safe-area-inset-bottom));
  }

  .theme-toggle {
    top: 124px;
    right: 48px;
  }
}

@media (max-width: 380px) {
  h1 {
    font-size: 1.4rem;
    letter-spacing: 0.08em;
  }
}

/* --- Landscape blocker for mobile --- */
.landscape-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px;
  overflow: hidden;
  touch-action: none;
  transition: background 0.3s ease;
}

.landscape-overlay canvas {
  position: absolute;
  inset: -60px;
  width: calc(100% + 120px);
  height: calc(100% + 120px);
  pointer-events: none;
}

.landscape-img {
  height: 60%;
  width: auto;
  object-fit: contain;
  border-radius: 4px;
  position: relative;
  z-index: 1;
}

.landscape-overlay p {
  font-family: 'EB Garamond', serif;
  font-size: 16px;
  color: var(--text-muted);
  white-space: nowrap;
  position: relative;
  z-index: 1;
}

@media (max-height: 500px) and (orientation: landscape) {
  .landscape-overlay {
    display: flex;
  }
  .stars,
  .clouds {
    display: none;
  }
}
