/* ==========================================================================
   Fonts
   ========================================================================== */

@font-face {
  font-family: "Noto Sans Math";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/noto-sans-math-math.woff2") format("woff2");
  unicode-range: U+1D400-1D7FF;
}

:root {
  --background-color: #222225;
  --font-color: #e8e9ed;
  --invert-font-color: #222225;
  --primary-color: #829ca5;
  --secondary-color: #a3abba;
  --tertiary-color: #a3abba;
  --error-color: #ff3c74;
  --progress-bar-background: #3f3f44;
  --progress-bar-fill: #829ca5;
  --code-bg-color: #3f3f44;
}

/* ==========================================================================
   Base
   ========================================================================== */

html, body {
  overflow-x: hidden;
}

html[data-theme="day"] {
  --background-color: #ebe7dd;
  --font-color: #292a27;
  --invert-font-color: #f4f1e9;
  --primary-color: #27758e;
  --secondary-color: #68716f;
  --tertiary-color: #526b6c;
  --progress-bar-background: #c8cbc5;
  --progress-bar-fill: #27758e;
  --code-bg-color: #dcd9d1;
}

.terminal-logo .terminal-prompt::after {
  content: none;
  display: none;
  animation: none;
}

/* ==========================================================================
   Grain overlay
   ========================================================================== */

.grain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.1;
  overflow: hidden;
  transform: translateZ(0);
}

html[data-theme="day"] .grain {
  opacity: 0.035;
  mix-blend-mode: multiply;
}

/* ==========================================================================
   Theme toggle
   ========================================================================== */

.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  align-self: flex-start;
  width: 1.75rem;
  height: 1.75rem;
  margin: calc(var(--global-space) * 2) 0 0 1.25rem;
  padding: 0.3rem;
  border: 0;
  border-radius: 50%;
  color: var(--secondary-color);
  background: transparent;
  cursor: pointer;
  appearance: none;
  transition: color 0.2s ease;
}

.theme-toggle:hover {
  color: var(--primary-color);
  background: transparent;
}

.theme-toggle:focus-visible {
  outline: 2px dotted var(--primary-color);
  outline-offset: 0.25rem;
}

.theme-icon {
  display: none;
  width: 100%;
  height: 100%;
}

.theme-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html[data-theme="night"] .theme-icon-night,
html[data-theme="day"] .theme-icon-day {
  display: block;
}

/* ==========================================================================
   Profile / Home page
   ========================================================================== */

.profile-identity {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin: 1rem 0 2.5rem 0;
}

.profile-portrait {
  flex: 0 0 180px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  display: block;
}

.profile-name {
  min-width: 0;
  margin: 0;
  color: #747b82;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.profile-name-alias {
  color: var(--font-color);
}

.profile-name-divider {
  color: #626970;
}

html[data-theme="day"] .profile-name {
  color: #292a27;
}

html[data-theme="day"] .profile-name-alias {
  color: #7a817e;
}

html[data-theme="day"] .profile-name-divider {
  color: #93958f;
}

.profile-frame {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
}

.profile-layer {
  position: absolute;
  inset: 0;
  display: block;
  opacity: 1;
}

.profile-layer-real {
  opacity: 0;
}

.profile-pic {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-pic-real {
  transform: scale(1.92);
  transform-origin: 50% 34%;
}

html[data-theme="day"] .profile-layer-anime {
  opacity: 0;
}

html[data-theme="day"] .profile-layer-real {
  opacity: 1;
}

.ludic-line {
  margin-top: 1.5rem;
}

/* ==========================================================================
   Favorite quote
   ========================================================================== */

.favorite-quote {
  margin: 1.2rem 0 2.5rem 0;
  padding-left: 0.2rem;
  font-size: 1.05rem;
  color: #cbd5e1;
  font-style: italic;
  letter-spacing: 0.3px;
  position: relative;
  display: inline-block;
}

html[data-theme="day"] .favorite-quote {
  color: #56615f;
}

html[data-theme="day"] .favorite-quote .quote-text {
  border-left-color: rgba(41, 42, 39, 0.28);
}

.favorite-quote .quote-text {
  border-left: 2px solid rgba(255,255,255,0.25);
  padding-left: 0.75rem;
  display: inline-block;
  cursor: default;
}

.favorite-quote .cross {
  font-style: normal;
  font-size: 1.85rem;
  font-weight: bold;
  margin-left: 0.75rem;
  vertical-align: baseline;
  position: relative;
  top: 0.1rem;
  display: inline-block;
  margin-top: 1.5rem;
}

/* ==========================================================================
   Tooltip (accessible)
   ========================================================================== */

.tooltip {
  position: relative;
}

.tooltip .tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  left: 0;
  top: 120%;
  background: rgba(15, 23, 42, 0.92);
  color: #e5e5e5;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  white-space: normal;
  max-width: 90vw;
  font-size: 0.75rem;
  transition: opacity 0.15s ease-out;
  z-index: 50;
  pointer-events: none;
  box-sizing: border-box;
}

.tooltip:hover .tooltip-text,
.tooltip:focus .tooltip-text,
.tooltip:focus-within .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* ==========================================================================
   Posts list
   ========================================================================== */

.posts-heading {
  margin-top: 1.5rem;
  margin-bottom: 2.5rem;
  text-align: left;
}

.posts-list {
  padding-left: 0;
  margin-left: 0;
  margin-bottom: 3rem;
}

.posts-list .date {
  display: block;
  font-size: 0.8rem;
  color: #9ca3af;
  margin-bottom: 0.25rem;
}

.posts-list .post + .post {
  margin-top: 3.5rem;
  padding-top: 3.5rem;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.posts-list .post h1 {
  margin-bottom: 1rem;
}

.posts-list .post h1 a {
  border-bottom: 1px dotted rgba(255,255,255,0.25);
  padding-bottom: 2px;
}

.posts-list .post h1 a:hover {
  border-bottom-color: rgba(255,255,255,0.5);
}

.posts-list .abstract {
  margin-bottom: 1.2rem;
}

.no-posts {
  font-size: 0.95rem;
  color: #9ca3af;
  font-style: italic;
  margin-top: 0.25rem;
}

/* ==========================================================================
   Archive
   ========================================================================== */

.archive-header {
  margin: 1.5rem 0 3rem;
}

.archive-header h1 {
  margin-bottom: 0.65rem;
}

.archive-header p {
  margin: 0;
  color: #9ca3af;
  font-size: 0.9rem;
}

.archive-index {
  padding: 0;
  margin: 0 0 3rem;
  list-style: none;
}

.archive-entry {
  display: grid;
  grid-template-columns: 7.25rem 6.5rem minmax(0, 1fr);
  gap: 1rem;
  align-items: baseline;
  padding: 1.35rem 0;
  border-top: 1px dotted rgba(255,255,255,0.2);
}

.archive-index .archive-entry::before {
  content: none;
}

.archive-entry:last-child {
  border-bottom: 1px dotted rgba(255,255,255,0.2);
}

.archive-entry time,
.archive-kind {
  color: #7f8793;
  font-size: 0.78rem;
  white-space: nowrap;
}

.archive-kind {
  letter-spacing: 0.04em;
}

.archive-title {
  display: inline;
  font-size: 1.02rem;
  line-height: 1.45;
  border-bottom: 1px dotted rgba(255,255,255,0.25);
}

.archive-title:hover,
.archive-title:focus {
  border-bottom-color: rgba(255,255,255,0.55);
}

.external-mark {
  display: inline-block;
  margin-left: 0.45rem;
  color: #7f8793;
  font-size: 0.75em;
  transform: translateY(-0.18em);
}

.archive-meta {
  margin: 0.45rem 0 0;
  color: #7f8793;
  font-size: 0.78rem;
  line-height: 1.5;
}

.no-archive {
  color: #9ca3af;
  font-style: italic;
}

html[data-theme="day"] .archive-header p,
html[data-theme="day"] .archive-entry time,
html[data-theme="day"] .archive-kind,
html[data-theme="day"] .archive-meta,
html[data-theme="day"] .external-mark,
html[data-theme="day"] .posts-list .date,
html[data-theme="day"] .no-posts,
html[data-theme="day"] .no-archive,
html[data-theme="day"] .meta {
  color: #616967;
}

html[data-theme="day"] .archive-entry,
html[data-theme="day"] .archive-entry:last-child,
html[data-theme="day"] .posts-list .post + .post {
  border-color: rgba(41, 42, 39, 0.18);
}

html[data-theme="day"] .archive-title,
html[data-theme="day"] .posts-list .post h1 a {
  border-bottom-color: rgba(41, 42, 39, 0.24);
}

html[data-theme="day"] .meta .tag {
  border-color: rgba(41, 42, 39, 0.28);
  background: rgba(41, 42, 39, 0.04);
}

/* ==========================================================================
   Post meta
   ========================================================================== */

.meta {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #9ca3af;
  line-height: 1.3;
}

.meta-label {
  text-transform: lowercase;
  opacity: 0.85;
}

.meta-value {
  font-weight: 500;
}

.meta-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  opacity: 0.9;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: baseline;
}

.meta-line + .meta-line {
  margin-top: 0.6rem;
}

.meta-separator {
  opacity: 0.5;
}

.meta .tag {
  display: inline-flex;
  align-items: center;
  padding: 0 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  text-decoration: none;
  color: inherit;
  font-size: 0.75rem;
  line-height: 1.6;
  background: rgba(15,23,42,0.5);
}

.meta .tag:hover {
  color: #ffffff;
  border-color: rgba(255,255,255,0.55);
  background: rgba(15,23,42,0.9);
}

/* ==========================================================================
   Footer
   ========================================================================== */

hr.footer-separator {
  border: none;
  margin: 3rem 0 2rem;
  text-align: center;
  opacity: 0.85;
}

hr.footer-separator::before {
  content: "--------------------------------------------------------------";
  color: rgba(255,255,255,0.20);
  font-family: "JetBrains Mono", "Fira Mono", "SF Mono", Menlo, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.footer-info {
  display: flex;
  align-items: baseline;
  margin-top: 1rem;
  padding-top: 1.5rem;
  border-top: 1px dotted rgba(255,255,255,0.35);
  color: #cbd5e1;
  font-size: 0.9rem;
  gap: clamp(1.25rem, 2.5vw, 2rem);
}

.location-status {
  margin-right: auto;
  opacity: 0.85;
  white-space: nowrap;
}

.location-status:hover {
  opacity: 1;
}

.contact-info {
  display: grid;
  justify-items: end;
  gap: 0.25rem;
  margin-top: 4rem;
  text-align: right;
  line-height: 1.4;
  color: #9ca3af;
  font-size: 0.9rem;
}

.contact-info strong {
  color: #e5e5e5;
}

html[data-theme="day"] .footer-info {
  color: #505c5a;
  border-top-color: rgba(41, 42, 39, 0.32);
}

html[data-theme="day"] .contact-info {
  color: #68716f;
}

html[data-theme="day"] .social-profile,
html[data-theme="day"] .social-icon,
html[data-theme="day"] .social-colon {
  color: #292a27;
}

html[data-theme="day"] .contact-info strong {
  color: #292a27;
}

.social-info {
  display: inline-flex;
  gap: clamp(0.8rem, 1.5vw, 1.25rem);
  line-height: 1.4;
}

.social-profile {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  white-space: nowrap;
  text-decoration: none;
}

.social-profile strong {
  color: inherit;
}

.social-label {
  display: inline-flex;
  align-items: baseline;
}

.social-icon,
.social-colon {
  color: #9ca3af;
}

.social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
}

.github-icon {
  width: 1em;
  height: 1em;
  fill: currentColor;
  transform: translateY(0.08em);
}

.unicode-symbol {
  font-family: "Noto Sans Math", sans-serif;
}

.pgp-link {
  color: #6e6e6e;
  text-decoration: underline;
}

.pgp-link:hover,
.pgp-link:focus {
  color: #a1a1a1;
}

html[data-theme="day"] .pgp-link {
  color: #68716f;
}

html[data-theme="day"] .pgp-link:hover,
html[data-theme="day"] .pgp-link:focus {
  color: #292a27;
}

/* PGP popup (accessible) */
.pgp-wrapper {
  position: relative;
  display: inline-block;
}

.pgp-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 0.5rem);
  right: 0;
  width: max-content;
  background: rgba(17, 24, 39, 0.98);
  padding: 0.55rem 0.75rem;
  border-radius: 4px;
  border: 1px solid rgba(148,163,184,0.25);
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  font-family: monospace;
  font-style: normal;
  font-size: 0.72rem;
  line-height: 1.5;
  color: #e5e5e5;
  text-align: left;
  white-space: nowrap;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.12s ease-out;
  pointer-events: none;
}

.pgp-popup-row {
  display: block;
}

.pgp-popup-row + .pgp-popup-row {
  margin-top: 0.25rem;
}

.pgp-popup-label {
  display: inline-block;
  width: 5.5rem;
  color: #6e7681;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pgp-popup-value {
  color: #e5e5e5;
}

html[data-theme="day"] .tooltip .tooltip-text,
html[data-theme="day"] .pgp-popup {
  background: rgba(247, 244, 237, 0.98);
  color: #292a27;
  border-color: rgba(41, 42, 39, 0.2);
  box-shadow: 0 8px 24px rgba(56, 50, 41, 0.18);
}

html[data-theme="day"] .pgp-popup-label {
  color: #737a76;
}

html[data-theme="day"] .pgp-popup-value {
  color: #292a27;
}

.pgp-wrapper:hover .pgp-popup,
.pgp-wrapper:focus-within .pgp-popup {
  display: block;
  opacity: 1;
}

@media (max-width: 640px) {
  .pgp-popup {
    right: auto;
    left: 0;
    white-space: normal;
    max-width: 90vw;
  }
  .pgp-popup-label {
    width: auto;
    display: block;
    margin-bottom: 0.15rem;
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
  .footer-info {
    gap: 1.25rem;
  }

  .contact-info {
    justify-items: start;
    text-align: left;
  }
}

@media (max-width: 640px) {
  .archive-header {
    margin-bottom: 2rem;
  }

  .archive-entry {
    grid-template-columns: auto 1fr;
    column-gap: 0.75rem;
    row-gap: 0.55rem;
  }

  .archive-kind {
    text-align: right;
  }

  .archive-item {
    grid-column: 1 / -1;
  }

  .footer-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .location-status {
    margin-right: 0;
    white-space: nowrap;
  }
}

@media (max-width: 600px) {
  .profile-identity {
    gap: 1.25rem;
  }

  .profile-name {
    font-size: 0.95rem;
    white-space: normal;
  }

  .favorite-quote {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
  }

  .favorite-quote .cross {
    font-size: 3.5rem;
    margin-left: 0;
    margin-top: 0;
    top: 0.5rem;
    flex-shrink: 0;
  }

  .tooltip .tooltip-text {
    position: absolute;
    white-space: normal;
    max-width: calc(100vw - 3rem);
    width: auto;
    left: 0;
    top: 100%;
    margin-top: 0.5rem;
  }
}

@media (max-width: 479px) {
  .terminal-nav {
    position: relative;
  }

  .theme-toggle {
    position: absolute;
    top: calc(var(--global-space) * 2);
    right: 0;
    margin: 0;
  }
}

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