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

html {
  --font-display: "Fraunces", Georgia, serif;
  --font-sans: "Instrument Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
  --max-width: 740px;
  --text: #1a1a1a;
  --text-secondary: #555;
  --bg: #fafafa;
  --accent: #c05621;
  --accent-hover: #a04a1c;
  --border: #e0e0e0;
  font-family: var(--font-mono);
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.75;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --text: #e1e1e1;
  --text-secondary: #999;
  --bg: #141414;
  --accent: #d4764a;
  --accent-hover: #e08a5e;
  --border: #2a2a2a;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.page {
  width: 100%;
  max-width: var(--max-width);
  padding: 4rem 1.5rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

header {
  margin-bottom: 3.5rem;
}

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

.avatar {
  width: 90px;
  height: 90px;
  border-radius: 9999px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--bg);
  background: var(--accent);
}

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

#theme-toggle:hover {
  border-color: var(--text-secondary);
}

html[data-theme="dark"] .icon-light {
  display: none;
}

html:not([data-theme="dark"]) .icon-dark {
  display: none;
}

h1 {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 400;
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}

main {
  display: flex;
  flex-direction: column;
}

details {
  border-bottom: 1px solid var(--border);
}

details:last-child {
  border-bottom: none;
}

summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0;
}

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

summary::marker {
  content: "";
}

summary::before {
  content: ">";
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: transform 0.15s ease;
  display: inline-block;
  width: 0.75rem;
}

details[open] > summary::before {
  transform: rotate(90deg);
}

summary h2 {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin: 0;
}

summary:hover h2,
summary:hover::before {
  color: var(--text);
}

details > p,
details > ul {
  margin-top: 0.5rem;
}

details[open] {
  padding-bottom: 1.5rem;
}

details p {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

details p:last-of-type {
  margin-bottom: 0;
}

.dash-list {
  list-style: none;
  margin-top: 0.75rem;
}

.dash-list li {
  padding-left: 1.25rem;
  position: relative;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  color: var(--text);
}

.dash-list li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--text-secondary);
}

ul.books .author {
  color: var(--text-secondary);
}

.shelf-experience.is-ready ~ ul.books {
  display: none;
}

.shelf-experience {
  display: flex;
  align-items: stretch;
  height: 24rem;
  margin: 0.5rem 0 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.shelf-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.shelf-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: pan-y;
}

.shelf-canvas.is-dragging {
  cursor: grabbing;
}

.shelf-caption {
  position: absolute;
  left: 1rem;
  bottom: 0.9rem;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.shelf-experience.is-focused .shelf-caption {
  opacity: 0;
  visibility: hidden;
}

.shelf-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 0.1rem;
}

.shelf-author {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.shelf-arrow {
  position: absolute;
  top: 42%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.shelf-arrow--left {
  left: 0.6rem;
}

.shelf-arrow--right {
  right: 0.6rem;
}

.shelf-arrow:hover {
  border-color: var(--text-secondary);
}

.shelf-experience.is-focused .shelf-arrow {
  opacity: 0;
  visibility: hidden;
}

.shelf-details {
  flex: 0 0 0px;
  width: 0;
  padding: 1.25rem 0 1rem;
  background: var(--bg);
  border-left: 0px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  visibility: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: flex-basis 0.3s ease, width 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
  white-space: nowrap;
}

.shelf-experience.is-focused .shelf-details {
  flex: 0 0 min(320px, 42%);
  width: min(320px, 42%);
  padding: 1.25rem 1.25rem 1rem;
  border-left-width: 1px;
  opacity: 1;
  visibility: visible;
  white-space: normal;
}

.shelf-back {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.shelf-back:hover {
  color: var(--text);
}

.shelf-details-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.3;
  color: var(--text);
}

.shelf-details-author {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.shelf-details-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.shelf-details-link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin-top: auto;
}

.shelf-details-link::after {
  content: " ↗";
}

.shelf-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.shelf-experience.is-ready .shelf-loading {
  opacity: 0;
  visibility: hidden;
}

footer {
  display: flex;
  gap: 1.25rem;
  padding-top: 2rem;
  padding-bottom: 1rem;
  margin-top: auto;
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
}

footer a:hover {
  color: var(--text);
}

@media (max-width: 768px) {
  .page {
    padding: 3rem 1.25rem;
  }

  h1 {
    font-size: 1.75rem;
  }
}

@media (max-width: 500px) {
  .page {
    padding: 2rem 1rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  .avatar {
    width: 70px;
    height: 70px;
    font-size: 1.3rem;
  }

  .shelf-experience {
    height: 34rem;
  }

  .shelf-experience.is-focused {
    flex-direction: column;
  }

  .shelf-experience.is-focused .shelf-stage {
    flex: 1 1 55%;
  }

  .shelf-experience.is-focused .shelf-details {
    flex: 0 0 45%;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
