/* =====================
   Design Tokens
   ===================== */
:root {
  --color-bg:              #E5F5FF;
  --color-ink:              #042353;
  --color-ink-hairline:     rgba(4, 35, 83, 0.05);

  --font-display: 'Piazzolla', Georgia, serif;
  --font-body:    'Barlow Semi Condensed', 'Avenir Next Condensed', 'Avenir Next', Avenir, sans-serif;
  --font-accent:  'Barlow', 'Avenir Next', Avenir, sans-serif;

  --space-xs:  0.5rem;
  --space-sm:  1rem;
  --space-md:  1.75rem;
  --space-lg:  3rem;
  --space-xl:  5rem;

  --max-width: 1440px;

  --ease-out-soft: cubic-bezier(0.16, 1, 0.3, 1);
}

@font-face {
  font-family: 'Font Awesome 6 Free';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('../assets/fonts/fa-solid-900.woff2') format('woff2');
}

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

html { font-size: 16px; }

body {
  color: var(--color-ink);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.bg-treatment {
  background-color: var(--color-bg);
  position: relative;
}

.bg-treatment::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 4px,
      rgba(185, 208, 228, 0.25) 4px,
      rgba(185, 208, 228, 0.25) 5px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 4px,
      rgba(185, 208, 228, 0.25) 4px,
      rgba(185, 208, 228, 0.25) 5px
    );
  mask-image: linear-gradient(to bottom, black 0%, transparent 25%);
  -webkit-mask-image: linear-gradient(to bottom, black 0%, transparent 25%);
  pointer-events: none;
  z-index: 0;
}

.bg-treatment > * {
  position: relative;
  z-index: 1;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
em { font-style: italic; }

/* =====================
   Keyboard focus
   ===================== */
:focus-visible {
  outline: 2px solid var(--color-ink);
  outline-offset: 3px;
  border-radius: 2px;
}

/* =====================
   Page layout
   ===================== */
.page {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 3rem;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

.content {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 1060px;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  padding: var(--space-lg) 0;
}

/* =====================
   Dividers
   ===================== */
.wavy-line {
  height: 8px;
  width: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='8' viewBox='0 0 40 8'%3E%3Cpath d='M0 4 C5 0 15 0 20 4 C25 8 35 8 40 4' fill='none' stroke='%23042353' stroke-opacity='0.3' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-size: 40px 8px;
  background-position: 0 0;
  animation-name: wavy-flow, fade-up;
  animation-duration: 9s, 0.8s;
  animation-timing-function: linear, var(--ease-out-soft);
  animation-iteration-count: infinite, 1;
  animation-fill-mode: none, both;
}

.content > div.wavy-line:nth-of-type(1) { animation-delay: 0s, 0.24s; }
.content > div.wavy-line:nth-of-type(2) { animation-delay: 0s, 0.5s; }
.content > div.wavy-line:nth-of-type(3) { animation-delay: 0s, 0.76s; }

@keyframes wavy-flow {
  from { background-position: 0 0; }
  to   { background-position: 40px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .wavy-line { animation: none; }
}

/* =====================
   Hero
   ===================== */
.hero {
  display: flex;
  flex-direction: column;
}

.display-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: 64px;
  line-height: normal;
  margin-bottom: 2rem;
}

.display-name-short { display: none; }

.tagline {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 32px;
  line-height: normal;
  margin-bottom: 0.75rem;
}

.identity-statement {
  font-family: var(--font-accent);
  font-style: italic;
  font-weight: 300;
  font-size: 24px;
  line-height: 1.4;
}

/* =====================
   Section titles (shared)
   ===================== */
.section-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 48px;
  line-height: normal;
}

.section-subtitle {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 16px;
  line-height: 1.6;
}

/* =====================
   My process
   ===================== */
.process {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  row-gap: 4rem;
  column-gap: 1.5rem;
}

.process-intro {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  flex: 0 0 auto;
  min-width: 412px;
}

.process-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex: 1 1 0%;
  min-width: 0;
  padding-top: var(--space-xs);
}

.process-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.process-rule {
  display: block;
  width: 20px;
  height: 1px;
  background: var(--color-ink);
  margin-bottom: 1.5rem;
}

.process-heading {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: normal;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.process-heading em {
  font-weight: 600;
  font-style: italic;
}

.process-body {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 22px;
  line-height: 1.4;
}

/* =====================
   My bookshelf
   ===================== */
.bookshelf {
  display: flex;
  flex-direction: column;
  gap: 4rem;
}

.book-list {
  display: flex;
  flex-direction: column;
}

.book {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 2rem 0;
}

.book:first-child { padding-top: 0; }
.book:last-child { padding-bottom: 0; }

.book + .book {
  border-top: 1px solid var(--color-ink-hairline);
}

.book-group {
  display: flex;
  align-items: flex-start;
  gap: 2.625rem;
  width: 412px;
  flex: 0 0 auto;
}

.book-cover {
  width: 64px;
  height: 82px;
  object-fit: cover;
  filter: grayscale(1);
  transition: filter 0.2s ease;
}

.book:hover .book-cover {
  filter: grayscale(0);
}

.book-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.book-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.5rem;
  line-height: normal;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.15s ease;
}

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

.ext-icon {
  font-size: 16px;
  margin-left: 4px;
}

.ext-icon::before {
  content: '\f14c';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
}

.book-author {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 16px;
  line-height: 1.6;
}

.book-desc {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  flex: 1 1 0%;
  min-width: 0;
}

.book-category {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: normal;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.book-summary {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 18px;
  line-height: 1.4;
}

/* =====================
   Footer note
   ===================== */
.footer-note {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 18px;
  line-height: 1.4;
}

.footer-link {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* =====================
   Siderail
   ===================== */
.siderail {
  position: sticky;
  top: 0;
  align-self: flex-start;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2rem;
  padding: 4rem 0.25rem 2.625rem 0.75rem;
  white-space: nowrap;
}

.siderail-mark {
  width: 16px;
  height: 16px;
  background: var(--color-ink);
  animation-name: mark-live, fade-up;
  animation-duration: 10s, 0.7s;
  animation-timing-function: ease-in-out, var(--ease-out-soft);
  animation-iteration-count: infinite, 1;
  animation-fill-mode: none, both;
  animation-delay: 0s, 0.1s;
}

@keyframes mark-live {
  0%   { transform: rotate(0deg);   border-radius: 15%; }
  50%  { transform: rotate(180deg); border-radius: 50%; }
  100% { transform: rotate(360deg); border-radius: 15%; }
}

@media (prefers-reduced-motion: reduce) {
  .siderail-mark { animation: none; }
}

.siderail-links {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  line-height: normal;
}

.siderail-links a { transition: opacity 0.15s ease; }
.siderail-links a:hover { opacity: 0.7; }

.bluesky-link { display: none; }

/* =====================
   Load-in animation
   ===================== */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.display-name,
.tagline,
.identity-statement,
.process-intro,
.process-item,
.bookshelf > .section-title,
.book,
.footer-note,
.siderail-links a {
  animation: fade-up 0.8s var(--ease-out-soft) both;
}

.display-name        { animation-delay: 0s; }
.tagline              { animation-delay: 0.08s; }
.identity-statement   { animation-delay: 0.16s; }

.process-intro        { animation-delay: 0.28s; }
.process-item:nth-child(1) { animation-delay: 0.34s; }
.process-item:nth-child(2) { animation-delay: 0.4s; }
.process-item:nth-child(3) { animation-delay: 0.46s; }

.bookshelf > .section-title { animation-delay: 0.54s; }
.book:nth-child(1) { animation-delay: 0.6s; }
.book:nth-child(2) { animation-delay: 0.66s; }
.book:nth-child(3) { animation-delay: 0.72s; }

.footer-note { animation-delay: 0.8s; }

.siderail-links a:nth-child(1) { animation-delay: 0.15s; }
.siderail-links a:nth-child(2) { animation-delay: 0.2s; }
.siderail-links a:nth-child(3) { animation-delay: 0.25s; }
.siderail-links a:nth-child(4) { animation-delay: 0.3s; }
.siderail-links a:nth-child(5) { animation-delay: 0.35s; }
.siderail-links a:nth-child(6) { animation-delay: 0.4s; }

@media (prefers-reduced-motion: reduce) {
  .display-name,
  .tagline,
  .identity-statement,
  .process-intro,
  .process-item,
  .bookshelf > .section-title,
  .book,
  .footer-note,
  .siderail-links a {
    animation: none;
  }
}

/* =====================
   404 page
   ===================== */
.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg) 1.5rem;
  text-align: center;
}

/* center via auto margins so short viewports scroll instead of clipping the top */
.error-page > :first-child { margin-top: auto; }
.error-page > :last-child { margin-bottom: auto; }

.error-code {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.125rem;
  line-height: normal;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.error-headline {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(40px, 8vw, 64px);
  line-height: normal;
}

.error-gif {
  max-width: min(292px, 80vw);
  height: auto;
}

.error-note {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.4;
  max-width: 44ch;
}

.error-link {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.error-page > * {
  animation: fade-up 0.8s var(--ease-out-soft) both;
}

.error-page > *:nth-child(1) { animation-delay: 0s; }
.error-page > *:nth-child(2) { animation-delay: 0.08s; }
.error-page > *:nth-child(3) { animation-delay: 0.16s; }
.error-page > *:nth-child(4) { animation-delay: 0.24s; }

@media (prefers-reduced-motion: reduce) {
  .error-page > * { animation: none; }
}

/* =====================
   Tablet (<=1020px)
   ===================== */
@media (max-width: 1020px) {
  .page {
    padding: 0 var(--space-lg);
    gap: 3rem;
  }

  .content {
    max-width: none;
    gap: 4rem;
  }

  .process {
    flex-direction: column;
    flex-wrap: nowrap;
    row-gap: 0;
    column-gap: 0;
    gap: 2.625rem;
  }

  .bookshelf {
    gap: 2.625rem;
  }

  .process-intro {
    min-width: 0;
  }

  .book {
    flex-direction: column;
    align-items: stretch;
    gap: 1.5rem;
  }

  .book-group {
    width: auto;
  }

  .book-meta {
    flex: 1 1 0%;
    min-width: 0;
  }
}

/* =====================
   Mobile
   ===================== */
@media (max-width: 768px) {
  .page {
    flex-direction: column;
    padding: 0 1.5rem;
    gap: 0;
  }

  .content {
    max-width: 100%;
    gap: 2.625rem;
    padding: var(--space-lg) 0;
  }

  .tagline { font-size: 28px; }

  .process {
    flex-direction: column;
    gap: 2rem;
  }

  .section-title { font-size: 36px; }

  .bookshelf { gap: 2rem; }

  .book {
    flex-direction: column;
    align-items: stretch;
    gap: 1.5rem;
    padding: 2rem 0;
  }

  .book-group {
    flex-direction: column;
    align-items: flex-start;
    width: auto;
    gap: 1.5rem;
  }

  .siderail {
    position: static;
    flex-direction: row;
    align-items: flex-end;
    justify-content: flex-start;
    width: 100%;
    padding: 0 0 2.625rem 0;
    gap: 2rem;
  }

  .siderail-links {
    flex: 1 1 0%;
    min-width: 0;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 0.75rem;
  }

  .bluesky-link { display: inline; }
}

/* =====================
   Small mobile
   ===================== */
@media (max-width: 420px) {
  .display-name-full { display: none; }
  .display-name-short { display: inline; }

  .display-name {
    font-size: 56px;
    letter-spacing: 0.02em;
  }
}
