@import url("https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@400;500;700&display=swap");

:root {
  --rail-w: 9.5rem;
  /* light theme: warm, muted parchment tones instead of pure white */
  --rail-bg: #efe6d6;
  --rail-fg: #1c2230;
  --rail-fg-dim: #5b5546;
  --page-bg: #e6d6ba;
  --card-bg: #f3ece0;
  --surface: #f8f3ea;
  --thumb-bg: #e7dccb;
  --fg: #1c2230;
  --rule: #d4c7b1;
  --foot-bg: #efe6d6;
  --foot-fg: #1c2230;
  --page-veil: rgba(230, 214, 186, 0.62);
  --tile-size: 6.25rem;
}

html[data-theme="dark"] {
  --rail-bg: #000;
  --rail-fg: #fff;
  --rail-fg-dim: #c9ccd1;
  --page-bg: #0b0d0e;
  --page-veil: rgba(11, 13, 14, 0.74);
  --card-bg: #1c1e1f;
  --surface: #26292b;
  --thumb-bg: #141617;
  --fg: #e6e9ee;
  --rule: #2c2f31;
  --foot-bg: #000;
  --foot-fg: #fafdf6;
}

* {
  box-sizing: border-box;
}

/* Root size grows with the viewport past 1920px wide, so zooming out (which widens the
   viewport) scales text and every rem-based size up instead of leaving it tiny. */
html {
  font-size: max(100%, 100vw / 120);
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  width: 100%;
  font-family: "Josefin Sans", "Segoe UI", system-ui, sans-serif;
  font-weight: 400;
  color: var(--fg);
  background-color: var(--page-bg);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-image:
    linear-gradient(var(--page-veil), var(--page-veil)),
    url("media/otter_pfp.png");
  background-repeat: repeat;
  background-size: auto, var(--tile-size) var(--tile-size);
  background-attachment: fixed, scroll;
}

a {
  text-decoration: none;
}

/* --- side rails --- */

.rail {
  position: fixed;
  top: 0;
  bottom: 0;
  width: var(--rail-w);
  padding: 2.5rem 0;
  background-color: var(--rail-bg);
  overflow-y: auto;
  z-index: 2;
}

.rail-left {
  left: 0;
  border-right: 1px solid var(--rule);
}

.rail-right {
  right: 0;
  border-left: 1px solid var(--rule);
}

.rail-item {
  display: block;
  width: 100%;
  padding: 1.75rem 0.625rem;
  border: 0;
  background: none;
  font: inherit;
  color: var(--rail-fg-dim);
  text-align: center;
  cursor: pointer;
  transition: color 0.18s ease, transform 0.18s ease;
}

.rail-item:hover,
.rail-item:focus-visible {
  color: var(--rail-fg);
  transform: translateY(-2px);
  outline: none;
}

.rail-item svg {
  width: 3.5rem;
  height: 3.5rem;
  display: block;
  margin: 0 auto 0.75rem;
}

.rail-label {
  display: block;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

/* --- center column --- */

.view {
  margin-left: var(--rail-w);
  margin-right: var(--rail-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1 0 auto;
  width: calc(100% - 4rem);
  max-width: 72rem;
  margin: 3rem auto 0;
  padding: 3rem 3.5rem;
  min-height: 60vh;
  background-color: var(--card-bg);
  border: 1px solid var(--rule);
}

/* --- name + social links, home page only --- */

.page-head {
  text-align: center;
  padding-bottom: 1.75rem;
}

.page-name {
  margin: 0;
  font-size: 3.2rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.page-tagline {
  max-width: 35rem;
  margin: 0.875rem auto 0;
  font-size: 1.05rem;
  opacity: 0.8;
}

.page-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.page-links a {
  display: inline-flex;
  color: inherit;
  opacity: 0.7;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.page-links a:hover,
.page-links a:focus-visible {
  opacity: 1;
  transform: translateY(-2px);
  outline: none;
}

.page-links svg {
  width: 1.875rem;
  height: 1.875rem;
}

/* --- portfolio area --- */

.portfolio {
  margin-top: 3.5rem;
}

.portfolio-title {
  margin: 0 0 0.375rem;
  font-size: 1.8rem;
}

/* --- tag list: every project and robot as a compact link --- */

.tag-group-label {
  margin: 1.5rem 0 0.625rem;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.625rem;
}

.tag {
  display: inline-block;
  padding: 0.4375rem 1rem;
  font-size: 0.95rem;
  color: inherit;
  background-color: var(--surface);
  border: 1px solid var(--rule);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.tag:hover,
.tag:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 0.375rem 0.875rem rgba(0, 0, 0, 0.16);
  outline: none;
}

body[data-page="home"] .portfolio-title {
  text-align: center;
}

.portfolio-title + .portfolio-grid {
  margin-top: 1.5rem;
}

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.25rem;
}

.portfolio-item {
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  background-color: var(--surface);
  border: 1px solid var(--rule);
}

.portfolio-item-title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.portfolio-item-title a {
  color: inherit;
}

.portfolio-item-text {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.8;
}

.portfolio-item-actions {
  margin: auto 0 0;
  padding-top: 1rem;
  font-size: 0.95rem;
}

.title_block {
  text-align: center;
  margin-bottom: 0.5rem;
}

/* --- embedded PDF --- */

.pdf-block {
  margin-top: 2rem;
}

.pdf-embed {
  display: block;
  width: 100%;
  height: 80vh;
  min-height: 30rem;
  background-color: var(--thumb-bg);
  border: 1px solid var(--rule);
}

.pdf-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 1.5rem;
  text-align: center;
  opacity: 0.75;
}

.pdf-actions {
  margin: 1rem 0 0;
  text-align: center;
}

.pdf-download,
.text-link {
  color: inherit;
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
  opacity: 0.8;
  transition: opacity 0.18s ease;
}

.pdf-download:hover,
.pdf-download:focus-visible,
.text-link:hover,
.text-link:focus-visible {
  opacity: 1;
  outline: none;
}

.robot-video {
  display: block;
  width: 100%;
  height: auto;
  background-color: #000;
}

.media-figure {
  margin: 0;
}

.media-caption {
  margin-top: 0.625rem;
  font-size: 0.9rem;
  text-align: center;
  opacity: 0.75;
}

/* --- embedded third-party frame (Desmos, and anything similar) --- */

.embed-block {
  margin-top: 2.5rem;
}

.embed-title,
.section-heading {
  margin: 0 0 1rem;
  font-size: 1.4rem;
  text-align: center;
}

/* --- plain content sections: notes, credits, and the like --- */

.page-section {
  margin-top: 3rem;
}

.section-text {
  max-width: 40rem;
  margin: 0 auto;
}

.section-text p {
  margin: 0;
}

.section-text p + p {
  margin-top: 1.25rem;
}

.section-figure {
  margin: 1.75rem 0;
}

.section-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: center;
}

.section-split .section-text {
  max-width: none;
  margin: 0;
}

.section-split .section-figure {
  margin: 0;
}

.section-copy .section-heading {
  margin-bottom: 0.75rem;
}

.section-split .section-video {
  max-width: 26.25rem;
}

@media screen and (max-width: 1080px) {
  .section-split {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

.section-image,
.section-video {
  display: block;
  width: 100%;
  max-width: 53.75rem;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--rule);
}

.section-image {
  background-color: #fff;
}

.section-video {
  background-color: #000;
}

.credits-list {
  max-width: 27.5rem;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.credits-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.625rem 0;
}

.credit-name {
  font-weight: 700;
}

.credit-role {
  opacity: 0.75;
}

.embed-frame {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 21.25rem;
  background-color: var(--thumb-bg);
  border: 1px solid var(--rule);
}

.game-frame {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #000;
  border: 1px solid var(--rule);
}

.audio-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
}

.audio-toggle {
  padding: 0.5rem 1.25rem;
  font: inherit;
  font-size: 0.95rem;
  color: inherit;
  background-color: var(--surface);
  border: 1px solid var(--rule);
  cursor: pointer;
  transition: opacity 0.18s ease;
}

.audio-toggle:hover,
.audio-toggle:focus-visible {
  opacity: 0.85;
  outline: none;
}

.audio-toggle[aria-pressed="true"] {
  background-color: var(--thumb-bg);
  opacity: 0.8;
}

.audio-volume {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.95rem;
}

.audio-volume input {
  width: 10rem;
  accent-color: currentColor;
}

.embed-frame.is-wide {
  aspect-ratio: 16 / 9;
  min-height: 0;
}

.embed-actions {
  margin: 1rem 0 0;
  text-align: center;
}

@media screen and (max-width: 1080px) {
  .pdf-embed {
    height: 60vh;
    min-height: 22.5rem;
  }
}

/* --- project status badge --- */

.status-row {
  margin: 0 0 0.5rem;
  text-align: center;
}

.status-badge {
  display: inline-block;
  padding: 0.3125rem 0.875rem 0.1875rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7a4a00;
  background-color: #ffd98a;
  border: 1px solid #e0a83a;
}

html[data-theme="dark"] .status-badge {
  color: #ffd98a;
  background-color: #3a2a0c;
  border-color: #7a5a1c;
}

.project-title .status-badge {
  margin-left: 0.625rem;
  vertical-align: middle;
}

/* --- progress diary: an index of updates, each update on its own page --- */

.diary-list {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.diary-list li + li {
  margin-top: 0.75rem;
}

.diary-link {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  padding: 1rem 1.25rem;
  color: inherit;
  background-color: var(--surface);
  border: 1px solid var(--rule);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.diary-link:hover,
.diary-link:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1.125rem rgba(0, 0, 0, 0.16);
  outline: none;
}

.diary-link .diary-date {
  flex: 0 0 auto;
  margin: 0;
}

.diary-link-title {
  font-weight: 700;
}

.diary-entry {
  max-width: 40rem;
  margin: 2.5rem auto 0;
}

.diary-date {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.65;
}

.diary-title {
  margin: 0 0 1rem;
  font-size: 1.5rem;
}

/* tall photos are capped and letterboxed so they don't run off the screen */
.diary-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  margin: 0 0 1.25rem;
  border: 1px solid var(--rule);
  background-color: var(--thumb-bg);
}

.diary-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  font-size: 0.95rem;
  color: var(--rail-fg-dim);
  background-color: var(--thumb-bg);
}

/* for updates with more than one picture, each with a caption */
.diary-figure {
  margin: 0 0 1.5rem;
}

.diary-figure .diary-image {
  margin-bottom: 0;
}

/* two or more pictures in a row; stacks on phones */
.diary-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  align-items: start;
  margin: 0 0 1.5rem;
}

.diary-figures .diary-figure {
  margin: 0;
}

.diary-text {
  margin: 0;
}

/* --- gallery carousel: one picture at a time, swipe or use the arrows --- */

.gallery {
  max-width: 40rem;
  margin: 0 auto;
}

.gallery-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  background-color: var(--surface);
  border: 1px solid var(--rule);
}

.gallery-track::-webkit-scrollbar {
  display: none;
}

.gallery-track:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.gallery-slide {
  flex: 0 0 100%;
  margin: 0;
  scroll-snap-align: start;
}

.gallery-slide img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background-color: var(--thumb-bg);
}

.gallery-caption {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  text-align: center;
}

.gallery-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 1rem;
}

.gallery-controls button {
  font: inherit;
  cursor: pointer;
}

.gallery-count {
  min-width: 3.5rem;
  font-size: 0.95rem;
  text-align: center;
  opacity: 0.75;
}

@media (prefers-reduced-motion: reduce) {
  .gallery-track {
    scroll-behavior: auto;
  }
}

/* parts list / bill of materials; scrolls sideways on narrow screens */
.parts-table-wrap {
  margin: 0 0 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--rule);
}

.parts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  background-color: var(--surface);
}

.parts-table th,
.parts-table td {
  padding: 0.625rem 0.875rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}

.parts-table th {
  font-weight: 700;
  background-color: var(--thumb-bg);
}

.parts-table tbody tr:last-child td {
  border-bottom: 0;
}

.parts-table td:nth-child(2),
.parts-table td:nth-child(3),
.parts-table td:nth-child(4) {
  white-space: nowrap;
}

/* pinned to the bottom of the screen, centered between the rails */
.diary-nav {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem;
  background-color: var(--card-bg);
  border: 1px solid var(--rule);
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.2);
  transform: translateX(-50%);
}

.diary-nav .button-link {
  white-space: nowrap;
}

.diary-nav .is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* room under the footer so the pinned bar never covers the end of the page */
body:has(.diary-nav) .foot {
  padding-bottom: 6rem;
}

@media screen and (max-width: 600px) {
  .diary-link {
    flex-direction: column;
    gap: 0.25rem;
  }

  .diary-nav {
    bottom: 0.75rem;
    gap: 0.375rem;
    padding: 0.375rem;
  }

  .diary-nav .button-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }
}

/* --- footer --- */

.foot {
  flex: 0 0 auto;
  margin-top: 5%;
  padding: 2% 0 3%;
  background-color: var(--foot-bg);
  color: var(--foot-fg);
  border-top: 1px solid var(--rule);
  text-align: center;
}

.foot .legal {
  color: var(--foot-fg);
  font-size: 0.9rem;
}

.foot .credit {
  display: block;
  margin-top: 0.5rem;
  color: var(--foot-fg);
  font-size: 0.85rem;
  opacity: 0.75;
}

/* --- theme toggle --- */

.theme-toggle .icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

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

/* --- mobile: left rail becomes a top bar, right rail folds into it --- */

@media screen and (max-width: 1080px) {
  .rail {
    position: static;
    width: 100%;
    padding: 0.5rem 0;
    text-align: center;
  }

  .rail-left {
    display: flex;
    justify-content: center;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .rail-right {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    width: auto;
    padding: 0;
    background: none;
    border: 0;
    z-index: 3;
  }

  .rail-item {
    width: auto;
    padding: 0.875rem 1.25rem;
  }

  .rail-right .rail-item {
    padding: 0.625rem;
    border-radius: 62.4375rem;
    background-color: var(--rail-bg);
    color: var(--rail-fg);
    border: 1px solid var(--rule);
  }

  .rail-item svg {
    width: 2rem;
    height: 2rem;
  }

  .rail-right .rail-label {
    display: none;
  }

  .view {
    margin: 0;
    min-height: auto;
  }

  .main {
    margin: 0;
    width: auto;
    max-width: none;
    padding: 8% 6%;
    border: 0;
  }

  .page-name {
    font-size: 2.2rem;
  }

  .foot {
    margin-top: 0;
    padding: 6% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rail-item {
    transition: none;
  }
}
