/* global theme variables and safe-area insets */
:root {
  --bg: #353535;
  --bg-deep: #2b2b2b;
  --fg: #dedede;
  --dim: #a8a8a8;
  --link: #efefef;
  --field: #2b2b2b;
  --good: #9fd49f;
  --bad: #e8a0a0;
  --glow: rgba(222, 222, 222, 0.16);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  background-color: var(--bg);
  background-image: radial-gradient(circle at center, #3b3b3b 0%, var(--bg-deep) 100%);
  color: var(--fg);
  font-family: "Courier New", Courier, "Liberation Mono", monospace;
  font-size: 17px;
  line-height: 1.7;
  text-transform: lowercase;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* subtle crt scanlines overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, 0.12) 3px,
    rgba(0, 0, 0, 0.12) 4px
  );
}

::selection {
  background: var(--fg);
  color: var(--bg-deep);
}

/* shared links and focus states */
a {
  color: var(--link);
  text-decoration: none;
  padding: 0.08em 0.25em;
  transition: background-color 0.12s steps(1), color 0.12s steps(1);
}

a:hover {
  background: var(--fg);
  color: var(--bg-deep);
  text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 1px dashed var(--fg);
  outline-offset: 3px;
}

/* centered layout for home and 404 */
body.page-center main {
  flex: 1;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  position: relative;
  z-index: 1;
}

/* standard layout for subpages */
body.page-sub main {
  flex: 1;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2.5rem;
  position: relative;
  z-index: 1;
}

/* breadcrumb and headings */
.crumb {
  margin: 0;
  font-size: 0.85rem;
  color: var(--dim);
}

.crumb a {
  padding: 0.05em 0.2em;
}

.head {
  margin-top: 2.25rem;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: 2.2rem;
  font-weight: normal;
  letter-spacing: -0.02em;
  text-shadow: 0 0 12px var(--glow);
}

/* typewriter subtitle effect: the text is revealed with clip-path, so no mask block is ever drawn */
.bio {
  margin: 0.3rem 0 0;
  color: var(--dim);
}

.bio .t {
  position: relative;
  display: inline-block;
}

.bio .t-text {
  display: inline-block;
  vertical-align: top;
  clip-path: inset(0 100% 0 0);
}

.cursor {
  position: absolute;
  left: 0;
  top: 50%;
  z-index: 1;
  width: 0.6em;
  height: 1.05em;
  margin: -0.525em 0 0 0.15em;
  background: var(--fg);
  box-shadow: 0 0 8px var(--glow);
}

/* per-page typewriter character steps (steps = number of characters) */
.t-home .t-text {
  animation: reveal 1.8s steps(18) 0.5s forwards;
}

.t-home .cursor {
  animation: type 1.8s steps(18) 0.5s forwards, blink 1.1s steps(1) infinite;
}

.t-about .t-text {
  animation: reveal 1.2s steps(13) 0.4s forwards;
}

.t-about .cursor {
  animation: type 1.2s steps(13) 0.4s forwards, blink 1.1s steps(1) infinite;
}

.t-tools .t-text {
  animation: reveal 1.5s steps(24) 0.4s forwards;
}

.t-tools .cursor {
  animation: type 1.5s steps(24) 0.4s forwards, blink 1.1s steps(1) infinite;
}

.t-dca .t-text {
  animation: reveal 2.2s steps(37) 0.5s forwards;
}

.t-dca .cursor {
  animation: type 2.2s steps(37) 0.5s forwards, blink 1.1s steps(1) infinite;
}

.t-be .t-text {
  animation: reveal 1.8s steps(27) 0.5s forwards;
}

.t-be .cursor {
  animation: type 1.8s steps(27) 0.5s forwards, blink 1.1s steps(1) infinite;
}

@keyframes reveal {
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes type {
  to {
    left: 100%;
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

hr {
  border: 0;
  border-top: 1px dashed var(--dim);
  margin: 2.1rem 0;
  opacity: 0.55;
}

/* about page cards */
.about-intro {
  margin: 0 0 1.4rem;
  font-size: 0.95rem;
  color: var(--fg);
}

.about-intro p {
  margin: 0;
}

.role-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.role-card {
  padding: 1rem 1.15rem;
  background: rgba(43, 43, 43, 0.75);
  border: 1px dashed var(--dim);
  text-align: left;
}

.role-card h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: normal;
  color: var(--link);
}

.role-card p {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  color: var(--dim);
}

/* tools index cards */
.tool-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tool-card {
  display: block;
  padding: 1rem 1.15rem;
  background: rgba(43, 43, 43, 0.75);
  border: 1px dashed var(--dim);
  text-align: left;
}

.tool-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.tool-title {
  font-size: 1.1rem;
  color: var(--link);
}

.tool-path {
  font-size: 0.8rem;
  color: var(--dim);
}

.tool-desc {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--dim);
}

.tool-card:hover {
  background: var(--fg);
  color: var(--bg-deep);
  border-color: var(--fg);
}

.tool-card:hover .tool-title,
.tool-card:hover .tool-path,
.tool-card:hover .tool-desc {
  color: var(--bg-deep);
}

/* calculator controls and output */
.tabs {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.tab {
  padding: 0.05em 0.25em;
  font: inherit;
  color: var(--dim);
  background: none;
  border: 0;
  cursor: pointer;
  text-transform: lowercase;
  transition: background-color 0.12s steps(1), color 0.12s steps(1);
}

.tab.on {
  color: var(--fg);
}

.tab:hover {
  background: var(--fg);
  color: var(--bg-deep);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--dim);
}

/* inside the grid, every input sits at the bottom of its row, even if a label wraps */
.grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.grid label input {
  margin-top: auto;
}

input {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.45rem 0.6rem;
  font: inherit;
  color: var(--fg);
  background: var(--field);
  border: 1px dashed var(--dim);
  border-radius: 0;
}

.hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--dim);
}

.big {
  margin: 0 0 1.2rem;
  text-align: center;
}

.big small {
  display: block;
  font-size: 0.85rem;
  color: var(--dim);
}

.big strong {
  font-size: 1.75rem;
  font-weight: normal;
  letter-spacing: -0.02em;
}

.big-lg strong {
  font-size: 2.2rem;
}

.big em {
  display: block;
  margin-top: 0.15rem;
  font-size: 1.1rem;
  font-style: normal;
}

.good {
  color: var(--good);
}

.bad,
.err {
  color: var(--bad);
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.15rem 0;
  border-bottom: 1px dotted rgba(143, 143, 143, 0.35);
}

.row span:first-child {
  color: var(--dim);
}

.about {
  font-size: 0.9rem;
  color: var(--dim);
}

.about h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: normal;
  color: var(--fg);
}

.about p {
  margin: 0 0 0.8rem;
}

/* 404 helper */
.not-found-text {
  margin: 0.3rem 0 0;
  color: var(--dim);
}

/* proportional unified footer with navigation above copyright */
footer {
  margin-top: auto;
  padding: 1.5rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  font-size: 0.8rem;
  color: var(--dim);
  text-align: center;
  position: relative;
  z-index: 1;
}

.footer-nav {
  margin-bottom: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.2rem 0.9rem;
  font-size: 0.85rem;
}

.footer-nav a,
.fm summary {
  padding: 0.1em 0.35em;
  color: var(--dim);
  white-space: nowrap;
}

.footer-nav a[aria-current="page"] {
  color: var(--fg);
}

.footer-nav a:hover,
.fm summary:hover,
.fm[open] summary {
  background: var(--fg);
  color: var(--bg-deep);
}

/* footer dropup menus (details/summary: no javascript, one open at a time via the name attribute) */
.fm {
  position: relative;
}

.fm summary {
  list-style: none;
  cursor: pointer;
}

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

.fm summary:focus-visible {
  outline: 1px dashed var(--fg);
  outline-offset: 3px;
}

.fm .pm::before {
  content: "+";
}

.fm[open] .pm::before {
  content: "-";
}

.fm-menu {
  position: absolute;
  bottom: 100%;
  left: 50%;
  z-index: 10;
  margin-bottom: 0.55rem;
  padding: 0.4rem 0.65rem;
  text-align: left;
  background: var(--bg-deep);
  border: 1px dashed var(--dim);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35);
  transform: translateX(-50%);
}

/* the last menu is anchored to the right edge so it never leaves the screen */
.fm:last-child .fm-menu {
  left: auto;
  right: 0;
  transform: none;
}

.fm-menu a {
  display: block;
  padding: 0.2em 0.45em;
  font-size: 0.85rem;
  color: var(--link);
  white-space: nowrap;
}

.fm-menu a:hover {
  color: var(--bg-deep);
}

.fm-menu .ref {
  margin-left: 0.3em;
  font-size: 0.7rem;
  color: var(--dim);
}

.fm-menu a:hover .ref {
  color: var(--bg-deep);
}

/* small screens: drop the [ ] brackets so every item fits on one row, and keep the tap targets comfortable */
@media (max-width: 480px) {
  .footer-nav {
    gap: 0.2rem 0.3rem;
    font-size: 0.8rem;
  }

  .footer-nav .b {
    display: none;
  }

  .footer-nav a,
  .fm summary {
    padding: 0.45em 0.4em;
  }

  .fm-menu a {
    padding: 0.4em 0.5em;
  }
}

@media (max-width: 350px) {
  .footer-nav {
    font-size: 0.75rem;
  }
}

/* the home footer fades in after the tagline has finished typing */
body.page-center footer {
  opacity: 0;
  animation: footer-in 0.5s ease 2.4s forwards;
}

@keyframes footer-in {
  to {
    opacity: 1;
  }
}

footer p {
  margin: 0;
  letter-spacing: 0.02em;
}

footer p a {
  color: var(--dim);
  padding: 0.05em 0.2em;
}

footer p a:hover {
  background: var(--fg);
  color: var(--bg-deep);
}

@media (max-width: 420px) {
  body {
    font-size: 15px;
  }

  body.page-center main,
  body.page-sub main {
    padding-left: 1rem;
    padding-right: 1rem;
  }


  .grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bio .t-text {
    animation: none;
    clip-path: none;
  }

  .cursor {
    animation: none;
    left: 100%;
  }

  body.page-center footer {
    opacity: 1;
    animation: none;
  }
}