@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700&family=Literata:opsz,wght@7..72,400;7..72,600&family=Libre+Baskerville:wght@400;700&display=swap');

:root {
  font-size: 16px;

  --borderColor: #000000;
  --backgroundColor: #F9F3EF;
  --shadowColor: #09382F;
  --contentColor: #F6DBDB;
  --contrastText: #09382F;
  --linkColor: #09382F;
  --linkHover: #000000;
  --errorColor: #b3261e;
  --errorTextColor: #ffffff;
  --infoColor: #1A4F8B;
  --bannerDim: rgba(0, 0, 0, 0.35);

  --headings: 'Raleway', sans-serif;
  --poppins: 'Poppins', sans-serif;

  --theme-heading-font: var(--headings);
  --theme-content-font: var(--poppins);

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;
  --leading-loose: 1.75;

  --measure-narrow: 45ch;
  --measure-normal: 66ch;
  --measure-wide: 75ch;
}

[data-font-theme='sans'] {
  --theme-heading-font: 'Sora', sans-serif;
  --theme-content-font: 'Sora', sans-serif;
}

[data-font-theme='ebook'] {
  --theme-heading-font: 'Literata', serif;
  --theme-content-font: 'Literata', serif;
}

[data-font-theme='scholarly'] {
  --theme-heading-font: 'Libre Baskerville', serif;
  --theme-content-font: 'Libre Baskerville', serif;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

body.sub-page {
  display: grid;
  grid-template-rows: 15vh auto auto;
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

body.sub-page section {
  position: relative;
  padding: 3% 0;
  display: block;
}

.page-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 5%;
  animation: fadeIn ease 1s;
  animation-fill-mode: both;
}

.card {
  background-color: var(--backgroundColor);
  border: 0.2rem solid var(--borderColor);
  border-radius: 0.4rem;
  padding: 1.5rem;
  box-shadow: 0.3rem 0.3rem var(--shadowColor);
  transition: all 0.2s ease;
}

.card:hover {
  transform: translateY(-0.2rem) translateX(0.2rem);
  box-shadow: 0.45rem 0.45rem var(--shadowColor);
}

.section-heading {
  font-family: var(--theme-heading-font);
  font-size: var(--text-2xl);
  color: var(--backgroundColor);
  padding: 1.2% 2%;
  background-color: var(--shadowColor);
  border: 0.2rem solid var(--borderColor);
  border-radius: 0.4rem;
  margin-bottom: 2%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
  box-shadow: 0.3rem 0.3rem var(--shadowColor);
}

.section-heading.collapsible {
  cursor: pointer;
}

.section-heading.collapsible:hover {
  transform: translateX(0.5%);
  box-shadow: 0.5rem 0.5rem var(--shadowColor);
}

.section-heading.static {
  cursor: default;
}

.section-heading.active {
  color: var(--borderColor);
  background-color: var(--contentColor);
}

.section-heading.active .title-text,
.section-heading.active .toggle-icon {
  color: var(--borderColor);
}

.title-text {
  flex: 1;
}

.toggle-icon {
  font-size: var(--text-xl);
  font-weight: bold;
  transition: transform 0.3s ease;
  min-width: 2rem;
  text-align: center;
}

/* Markdown-rendered content */
code {
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  background-color: var(--shadowColor);
  color: var(--backgroundColor);
  padding: 0.05rem 0.3rem;
  border-radius: 0.25rem;
}

pre {
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  background-color: var(--shadowColor);
  color: var(--backgroundColor);
  border: 0.15rem solid var(--borderColor);
  border-radius: 0.4rem;
  padding: 1rem;
  overflow-x: auto;
}

pre code {
  background-color: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
}

.card-title {
  font-family: var(--theme-heading-font);
  color: var(--shadowColor);
  font-size: var(--text-xl);
  margin: 0 0 0.5rem 0;
}

.card-excerpt {
  font-family: var(--theme-content-font);
  font-size: var(--text-base);
  color: var(--borderColor);
  line-height: var(--leading-relaxed);
  margin: 0;
}

.card-date {
  color: var(--shadowColor);
  font-family: var(--theme-content-font);
  font-size: var(--text-sm);
  margin: 0 0 0.8rem 0;
  font-weight: normal;
  opacity: 0.85;
}

.card-link {
  display: inline-block;
  margin-top: 0.8rem;
  color: var(--linkColor);
  text-decoration: none;
  border-bottom: 0.1rem solid var(--linkColor);
  font-size: var(--text-sm);
  transition: all 0.2s ease;
}

.card-link:hover {
  color: var(--linkHover);
  border-bottom-color: var(--linkHover);
}

@media (max-width: 720px) {
  :root {
    font-size: 14px;
  }

  body.sub-page {
    overflow-y: auto;
    grid-template-rows: auto;
  }

  body.sub-page section {
    min-height: auto;
    padding: 10% 2% 3%;
  }

  body.sub-page .page-container {
    padding: 0 3%;
  }

  body header {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 20;
    box-sizing: border-box;
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 18% 5% 5%;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 1.5rem;
    text-align: center;
    background-color: var(--backgroundColor);
    border: none;
    transform: translateX(100%);
    transition: transform 0.3s ease, visibility 0s linear 0.3s;
    overflow-y: auto;
    visibility: hidden;
  }

  body header.is-open {
    visibility: visible;
    transform: translateX(0);
    transition: transform 0.3s ease;
  }

  body header nav {
    width: 100%;
  }

  body header nav ul {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  body header nav ul li a {
    color: var(--borderColor);
    font-size: var(--text-lg);
  }

  #menuIcon {
    top: 0%;
    right: 4%;
    cursor: pointer;
    visibility: visible;
    position: absolute;
    z-index: 30;
    color: var(--shadowColor);
    font-size: var(--text-4xl);
    transition: transform 0.3s ease;
  }

  #menuIcon.is-open {
    transform: rotate(180deg);
  }

  body footer {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
    text-align: center;
    font-size: var(--text-xs);
    width: 100%;
    margin-top: auto;
    padding: 0.5rem 0;
  }

  body footer #footer_nav {
    gap: 0.75rem;
    flex-wrap: nowrap;
  }

  body footer #footer_nav .link-svg {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
  }

  /* Touch-tap replacements for :hover. Hover is neutralized below so taps
     never leave sticky :hover states; .tapped (toggled by shared.js) restores
     the feedback while the finger is down, or persists for underline effects. */
  .card:hover {
    transform: none;
    box-shadow: 0.3rem 0.3rem var(--shadowColor);
  }

  .card.tapped {
    transform: translateY(-0.2rem) translateX(0.2rem);
    box-shadow: 0.45rem 0.45rem var(--shadowColor);
  }

  .section-heading.collapsible:hover {
    transform: none;
    box-shadow: 0.3rem 0.3rem var(--shadowColor);
  }

  .section-heading.collapsible.tapped {
    transform: translateX(0.5%);
    box-shadow: 0.5rem 0.5rem var(--shadowColor);
  }

  .card-link:hover {
    color: var(--linkColor);
    border-bottom-color: var(--linkColor);
  }

  .card-link.tapped {
    color: var(--linkHover);
    border-bottom-color: var(--linkHover);
  }

  footer #footer_nav li:hover .link-svg {
    transform: none;
  }

  footer #footer_nav li a.tapped .link-svg {
    transform: scale(1.15);
  }

  #font-switcher-toggle:hover {
    transform: none;
    box-shadow: 0.2rem 0.2rem var(--shadowColor);
  }

  #font-switcher-toggle.tapped {
    transform: translateY(-0.1rem) translateX(0.1rem);
    box-shadow: 0.3rem 0.3rem var(--shadowColor);
  }

  #font-switcher-toggle[data-tooltip]:hover::after,
  #pro-button[data-tooltip]:hover::after {
    opacity: 0;
  }

  #font-switcher-menu button:hover {
    border-color: var(--backgroundColor);
  }

  #font-switcher-menu button.tapped {
    border-color: var(--borderColor);
  }

  #pro-button:hover {
    transform: none;
    box-shadow: 0.2rem 0.2rem var(--shadowColor);
  }

  #pro-button.tapped {
    transform: translateY(-0.1rem) translateX(0.1rem);
    box-shadow: 0.3rem 0.3rem var(--shadowColor);
  }

  .profiles-strip:hover {
    animation-play-state: running;
  }

  .profiles-strip.tapped {
    animation-play-state: paused;
  }

  .profiles-item:hover::after {
    transform: scaleX(0);
  }

  .profiles-item.tapped::after {
    transform: scaleX(1);
  }
}

/* Shared footer */
footer {
  animation: fadeIn ease 2s;
  animation-fill-mode: forwards;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  margin-top: 1.5rem;
  padding: 2.5rem 2rem 3rem;
}

footer #footer_nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

footer #footer_nav a {
  display: inline-flex;
  align-items: center;
  position: relative;
  text-decoration: none;
}

footer #footer_nav .link-svg {
  display: block;
  width: 2.75rem;
  height: 2.75rem;
  transition: transform 0.2s ease;
}

footer #footer_nav li:hover .link-svg {
  transform: scale(1.15);
}

footer #footer_nav .link-svg .link-bg {
  fill: var(--backgroundColor);
}

footer #footer_nav .link-svg .link-path {
  fill: var(--borderColor);
}

#font-switcher {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

#font-switcher-toggle {
  box-sizing: border-box;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border-radius: 50%;
  border: 0.2rem solid var(--borderColor);
  background-color: var(--contentColor);
  color: var(--borderColor);
  font-family: var(--headings);
  font-size: var(--text-base);
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0.2rem 0.2rem var(--shadowColor);
  transition: all 0.2s ease;
}

#font-switcher-toggle:hover {
  transform: translateY(-0.1rem) translateX(0.1rem);
  box-shadow: 0.3rem 0.3rem var(--shadowColor);
}

#font-switcher-toggle[data-tooltip] {
  position: relative;
}

#font-switcher-toggle[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 120%;
  top: 50%;
  transform: translateY(-50%);
  background-color: var(--contentColor);
  color: var(--borderColor);
  font-family: var(--poppins);
  font-size: var(--text-xs);
  padding: 0.35rem 0.6rem;
  border-radius: 0.25rem;
  border: 0.1rem solid var(--borderColor);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 200;
}

#font-switcher-toggle[data-tooltip]:hover::after {
  opacity: 1;
}

#font-switcher-menu {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  background-color: var(--backgroundColor);
  border: 0.15rem solid var(--borderColor);
  border-radius: 0.4rem;
  box-shadow: 0.2rem 0.2rem var(--shadowColor);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
}

#font-switcher-menu[hidden] {
  display: none;
}

#font-switcher-menu button {
  background: none;
  border: 0.1rem solid var(--backgroundColor);
  padding: 0.5rem 0.75rem;
  font-size: var(--text-sm);
  font-family: var(--poppins);
  color: var(--shadowColor);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  border-radius: 0.25rem;
  transition: border-color 0.2s ease, background 0.2s ease;
  width: 100%;
}

#font-switcher-menu button:hover {
  border-color: var(--borderColor);
}

#font-switcher-menu button.active {
  background-color: var(--shadowColor);
  color: var(--backgroundColor);
}

#pro-button {
  box-sizing: border-box;
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 0.2rem solid var(--borderColor);
  background-color: var(--contentColor);
  color: var(--borderColor);
  cursor: pointer;
  box-shadow: 0.2rem 0.2rem var(--shadowColor);
  transition: all 0.2s ease;
}

#pro-button:hover {
  transform: translateY(-0.1rem) translateX(0.1rem);
  box-shadow: 0.3rem 0.3rem var(--shadowColor);
}

#pro-button[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 120%;
  top: 50%;
  transform: translateY(-50%);
  background-color: var(--contentColor);
  color: var(--borderColor);
  font-family: var(--poppins);
  font-size: var(--text-xs);
  padding: 0.35rem 0.6rem;
  border-radius: 0.25rem;
  border: 0.1rem solid var(--borderColor);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 200;
}

#pro-button[data-tooltip]:hover::after {
  opacity: 1;
}

#pro-button svg {
  width: 1.6rem;
  height: 1.6rem;
  fill: var(--borderColor);
}

.profiles-block {
  width: 100vw;
  margin: clamp(1.5rem, 5vh, 3.5rem) calc(50% - 50vw);
}

.profiles {
  font-family: var(--theme-content-font);
  font-size: clamp(1rem, 3vw, 1.5rem);
  font-weight: 500;
  color: var(--backgroundColor);
  margin: 0;
  height: clamp(2.5rem, 7vh, 3rem);
  line-height: clamp(2.5rem, 7vh, 3rem);
  overflow: hidden;
  position: relative;
  width: 100%;
  align-self: stretch;
  background-color: var(--shadowColor);
}

.profiles-strip {
  display: flex;
  flex-direction: row;
  width: max-content;
  animation: profiles-marquee 22s linear infinite;
  will-change: transform;
}

.profiles-strip:hover {
  animation-play-state: paused;
}

.profiles-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex: 0 0 auto;
}

@keyframes profiles-marquee {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-50%);
  }
}

.profiles-item {
  flex: 0 0 auto;
  height: clamp(2.5rem, 7vh, 3rem);
  line-height: clamp(2.5rem, 7vh, 3rem);
  white-space: nowrap;
  display: flex;
  align-items: center;
  position: relative;
  transition: color 0.15s ease;
}

.profiles-item::after {
  content: '';
  position: absolute;
  left: 0.1rem;
  right: 0.1rem;
  bottom: 0.4rem;
  height: 0.18rem;
  border-radius: 0.1rem;
  background-color: var(--backgroundColor);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}

.profiles-item:hover::after {
  transform: scaleX(1);
}

.profiles-sep {
  color: var(--backgroundColor);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin: 0 1.2rem;
  align-self: center;
}

.tooltip {
  position: fixed;
  z-index: 3000;
  display: none;
  max-width: 280px;
  background-color: var(--contentColor);
  border: 0.1rem solid var(--borderColor);
  border-left: 0.2rem solid var(--shadowColor);
  border-radius: 0.4rem;
  padding: 0.6rem 0.8rem;
  font-family: var(--theme-content-font);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--borderColor);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
