/* =========================================================================
   A warm-paper, bookish theme in the spirit of a cozy personal website.
   ========================================================================= */

:root {
  /* palette — notebook (cream paper, blue ink) */
  --paper-base: #fcf9f2;
  --paper-light: #f8f5ec;
  --paper-hover: #f5f1e6;
  --ink-primary: #1e1c18;
  --ink-secondary: #4a4540;
  --ink-muted: #8a8278;
  --ink-red: #b04030;
  --link: #3366aa;
  --link-visited: #5a4080;
  --header-color: #2a3a60;
  --header-hover: #1a2a40;
  --divider: #d8d0c4;
  --selection: #d8dce8;
  --code-bg: #f8f5ec;
  --tomb: #993333;

  /* gallery — tight grid matching reference */
  --gallery-gap: 1px;
  --gallery-zoom: 1.069;

  /* type */
  --font-main: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-code: "JetBrains Mono", "Fantasque Sans Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* sizes */
  --paragraph-size: 1.37rem;
  --paragraph-size-mobile: 1.22rem;
  --paragraph-line-height: 1.85rem;
  --paragraph-line-height-mobile: 1.9rem;
  --paragraph-width: 40rem;
  --header-width: 50rem;

  --section-one: 3.6rem;
  --section-two: 2.2rem;
  --section-three: 1.7rem;
  --section-four: 1.4rem;
  --section-five: 1.3rem;
  --section-six: 1.2rem;

  --media-width: 55.125rem;
}

/* ------------------------------------------------------------------ base */

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

html {
  scroll-behavior: smooth;
}

body.article {
  position: relative;
  margin: 0;
  background: var(--paper-base);
  color: var(--ink-primary);
  font-family: var(--font-main);
  font-size: var(--paragraph-size);
  line-height: var(--paragraph-line-height);
  font-weight: 500;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  margin-bottom: 3rem;
  background-image: var(--bg-texture, radial-gradient(rgba(0, 0, 0, 0.028) 1.4px, transparent 1.4px));
  background-size: var(--bg-texture-size, 8px 8px);
}

/* the thin frame around the whole page */
/* body::before is controlled by design-lab.js (no frame by default) */
body.article::before { display: none; }

@media (max-width: 600px) {
  body.article::before {
    display: none;
  }
}

::selection {
  background: var(--selection);
}

/* ----------------------------------------------------------------- header */

.header {
  width: var(--header-width);
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 0.9375rem;
  padding-right: 0.9375rem;
}

.header .section-1 {
  color: var(--ink-primary);
  margin-top: 2.25rem;
  margin-bottom: 0;
  font-size: var(--section-one);
  line-height: calc(var(--section-one) + 0.2rem);
  font-weight: 500;
  letter-spacing: -0.01rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

#myface {
  height: 6.5rem;
  width: 6.5rem;
  border-radius: 50%;
  flex: 0 0 auto;
}

.header .menu {
  font-size: 1.15rem;
  border-bottom: 1px solid var(--divider);
  line-height: 1.5;
  padding: 0.5rem;
  color: inherit;
  display: flex;
  flex-flow: row wrap;
  gap: 0.15rem 0.4rem;
}

.header .menu .nav {
  display: inline;
}

.header .menu .email {
  color: var(--ink-muted);
}

.header .menu .email a {
  color: inherit;
}

.hetime {
  color: var(--ink-muted);
  font-size: 0.95rem;
}

/* ---------------------------------------------------------------- writing */

.writing {
  width: var(--paragraph-width);
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  margin-top: 1rem;
  padding-left: 0.9375rem;
  padding-right: 0.9375rem;
}

.writing p {
  margin: 0 0 1rem;
}

.writing p + p {
  margin-top: 1rem;
}

/* --------------------------------------------------------------- headings */

.section-2,
.section-3,
.section-4,
.section-5,
.section-6 {
  font-family: inherit;
  font-weight: 600;
  color: var(--header-color);
  letter-spacing: -0.005rem;
  page-break-after: avoid;
}

.section-2 {
  font-size: var(--section-two);
  padding-top: 1.6rem;
  margin: 0 0 0.6rem;
}

.section-3 {
  font-size: var(--section-three);
  margin: 1.6rem 0 0.4rem;
}

.section-4 {
  font-size: var(--section-four);
  margin: 1.2rem 0 0.3rem;
}

.section-5 { font-size: var(--section-five); margin: 1rem 0 0.3rem; }
.section-6 { font-size: var(--section-six); margin: 1rem 0 0.3rem; }

/* --------------------------------------------------------------- links */

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--ink-primary);
  transition: 80ms;
  cursor: pointer;
}

a:hover {
  color: var(--link);
  border-bottom: none;
}

a:visited {
  color: inherit;
}

.rss-link,
#myface,
.title-text a {
  border-bottom: none;
}

/* --------------------------------------------------------------- lists */

ul,
ol {
  margin: 0 0 1rem;
  padding-left: 1.6rem;
}

ul > li,
ol > li {
  margin: 0.25rem 0;
}

li > p {
  margin: 0.2rem 0;
}

.post-list {
  list-style: none;
  padding-left: 0;
}

.post-list li {
  margin: 0.45rem 0;
  padding-left: 1.4rem;
  text-indent: -1.4rem;
}

.post-list .date {
  color: var(--ink-muted);
  font-size: 0.95rem;
  margin-left: 0.4rem;
}

/* ------------------------------------------------------------- quote */

blockquote {
  margin: 1.5rem 2.5rem;
  padding-left: 1rem;
  font-size: 1.3rem;
  line-height: 1.65;
  color: var(--ink-secondary);
  border-left: 1px solid var(--divider);
  font-style: italic;
}

/* --------------------------------------------------------------- code */

code {
  font-family: var(--font-code);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--divider);
  border-radius: 4px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  line-height: 1.5;
  margin: 1.2rem 0;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.92rem;
}

/* -------------------------------------------------------------- table */

table {
  border-collapse: collapse;
  border-style: double;
  border-color: var(--ink-primary);
  margin: 1.2rem auto;
  max-width: 100%;
  font-size: 1.2rem;
}

th,
td {
  padding: 0.5rem 1rem;
  text-align: left;
  border-left: 1px solid var(--ink-primary);
}

th {
  border-bottom: 1px solid var(--ink-primary);
}

/* ------------------------------------------------------------- misc */

hr {
  border: none;
  border-top: 1px solid var(--divider);
  margin: 2rem 0;
}

.center {
  text-align: center;
}

.date-line {
  color: var(--ink-muted);
  font-size: 1.1rem;
}

details {
  border: 1px dotted var(--ink-primary);
  border-radius: 2px;
  padding: 0.4rem 1rem;
  margin: 0.8rem 0;
}

summary {
  cursor: pointer;
}

img {
  max-width: 100%;
}

/* ------------------------------------------------------------- gallery */

.gallery-container {
  max-width: var(--media-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: 0.9375rem;
  padding-right: 0.9375rem;
}

.gallery {
  max-width: 100%;
  min-width: 1px;
  width: calc(100% - var(--gallery-gap));
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-evenly;
  align-content: flex-start;
  align-items: center;
  gap: var(--gallery-gap) var(--gallery-gap);
  line-height: 0;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.gallery-column {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--gallery-gap);
  align-self: stretch;
}

.gallery-row-link {
  display: block;
  height: 100%;
}

.gallery-item {
  background-position: center;
  background-repeat: no-repeat;
  display: block;
}

.gallery-item .item {
  width: 100%;
  height: auto;
  transition: all 700ms ease-in-out;
}

.gallery-item:hover .item {
  transform: scale(var(--gallery-zoom));
}

/* flex basis helpers */
:root {
  --flex-one: calc(100% - var(--gallery-gap));
  --flex-two: calc(100% / 2 - var(--gallery-gap));
  --flex-three: calc(100% / 3 - var(--gallery-gap));
  --flex-four: calc(100% / 4 - var(--gallery-gap));
  --flex-five: calc(100% / 5 - var(--gallery-gap));
}

.flex-1 { flex-basis: var(--flex-one); }
.flex-2 { flex-basis: var(--flex-two); }
.flex-3 { flex-basis: var(--flex-three); }
.flex-4 { flex-basis: var(--flex-four); }
.flex-5 { flex-basis: var(--flex-five); }

.hide-overflow { overflow: hidden; }
.ease-transition { transition: all 300ms ease-in-out; }

@media (max-width: 900px) {
  .gallery {
    width: calc(100% - var(--gallery-gap));
  }
  .flex-3 { flex-basis: var(--flex-two); }
  .flex-4 { flex-basis: var(--flex-two); }
  .flex-5 { flex-basis: var(--flex-three); }
}

@media (max-width: 600px) {
  .flex-3 { flex-basis: var(--flex-one); }
  .flex-4 { flex-basis: var(--flex-one); }
  .flex-5 { flex-basis: var(--flex-one); }
}

/* ------------------------------------------------------------- footer */

.footer {
  width: var(--paragraph-width);
  max-width: 100%;
  margin: 3rem auto 0;
  padding: 0 0.9375rem;
}

.footer .menu {
  font-size: 1rem;
  border-top: 1px solid var(--divider);
  padding: 0.75rem 0.5rem;
  color: var(--ink-muted);
  display: flex;
  flex-flow: row wrap;
  gap: 0.2rem 0.5rem;
}

.footer .menu a {
  color: var(--ink-muted);
  border-bottom: none;
}

.footer .menu a:hover {
  color: var(--link);
}

/* --------------------------------------------------------- responsive */

@media (max-width: 600px) {
  body.article {
    font-size: var(--paragraph-size-mobile);
    line-height: var(--paragraph-line-height-mobile);
  }

  .header .section-1 {
    font-size: calc(var(--section-one) * 0.78);
    gap: 0.6rem;
  }

  #myface {
    height: 4.5rem;
    width: 4.5rem;
  }

  .writing,
  .footer {
    padding-left: 1.37rem;
    padding-right: 1.37rem;
  }

  blockquote {
    margin: 1.2rem 1rem;
  }
}
