/* ==========================================================================
   The Gradual Steep — site styles
   Moderate refresh: preserves the original identity (dark textured ground,
   paper content panel, overlapping wordmark, grey palette, Nori/Transat type)
   while becoming fluid, responsive and accessible.
   ========================================================================== */

:root {
  /* Font stacks (the Transat/Nori webfonts with system fallbacks) */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --font-body: TransatStandard, var(--font-sans);
  --font-bold: TransatBold, var(--font-sans);
  --font-light: TransatLight, var(--font-sans);
  --font-display: Nori, Georgia, "Times New Roman", serif;

  /* Palette */
  --ink: #555;
  --ink-soft: #777;
  --muted: #999;
  --heading: #4a4a4a;
  --light: #f0f0f0;
  --light-dim: #bbb;
  --link: #6f6f6f;
  --link-hover: #444;
  --card: #ffffff;
  --card-border: #ececec;
  --code-bg: #fafafa;

  /* Layout */
  --container: 880px; /* keeps the reading measure near the ~66-75 char ideal */
  --gutter: clamp(1rem, 4vw, 2.25rem);

  /* Wordmark (SVG is 288 x 140) */
  --wordmark-w: clamp(220px, 38vw, 288px);
  --wordmark-h: calc(var(--wordmark-w) * 140 / 288);
}

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

html {
  font-family: var(--font-body);
  font-weight: normal;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  line-height: 1.5;
  background-image: url("../images/dark-background.png");
  color: var(--ink);
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  color: var(--link-hover);
}
a:focus-visible {
  outline: 2px solid #888;
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

h1 {
  font-family: var(--font-display);
  font-weight: normal;
  font-style: normal;
  font-size: clamp(2.25rem, 6vw, 4rem);
  line-height: 1.4;
  color: var(--heading);
  margin: 0 0 0.25rem;
}

h2 {
  font-family: var(--font-bold);
  font-weight: normal;
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  margin: 0 0 0.5rem;
}

h3 {
  font-family: var(--font-bold);
  font-weight: normal;
  font-size: clamp(1.3rem, 3.2vw, 1.6rem);
  margin: 0 0 0.15rem;
}

h4 {
  font-family: var(--font-bold);
  font-weight: normal;
  /* in-post section headings: always >= body text, below h3 */
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  margin: 1.5rem 0 1.125rem;
  color: #606060;
}

/* Deeper levels are unused today; keep them at body size (never smaller) */
h5,
h6 {
  font-family: var(--font-bold);
  font-weight: normal;
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.25rem);
  margin: 1.5rem 0 1rem;
  color: #606060;
}

p {
  margin: 1.125rem 0;
}

em {
  font-style: italic;
}

/* Code */
pre,
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Courier New", monospace;
}
code {
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  background: #f3f3f3;
  border: 1px solid var(--card-border);
  border-radius: 3px;
}
pre {
  font-size: 0.9375rem;
  line-height: 1.5;
  padding: 1rem 1.1rem;
  background: var(--code-bg);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  overflow-x: auto;
}
pre code {
  font-size: inherit;
  padding: 0;
  background: none;
  border: 0;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

header {
  font-family: var(--font-light);
  font-size: clamp(1.25rem, 3.5vw, 2rem);
  color: var(--light);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

header .center {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0.6rem var(--gutter);
}

header .title-name {
  font-size: clamp(1.9rem, 5.5vw, 3.25rem);
}

header nav {
  order: -1; /* nav on the left, name on the right (original layout) */
}

header nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

header nav a {
  color: var(--light);
}
header nav a:hover {
  color: #ccc;
}

/* --------------------------------------------------------------------------
   Main / content column
   -------------------------------------------------------------------------- */

.main {
  background-image: url("../images/body-background.jpg");
  box-shadow: 0 0 8px 5px rgba(33, 33, 33, 0.33);
}

.content {
  position: relative;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0.5rem var(--gutter) 2.5rem;
}

/* Wordmark: overlaps the top of the article card via a negative bottom margin
   so the effect scales with the (fluid) wordmark size. */
.fixed-title {
  position: relative;
  z-index: 10;
  margin: clamp(1rem, 3vw, 2rem) 0 0 0.3rem;
}
.fixed-title.svg {
  width: var(--wordmark-w);
  height: var(--wordmark-h);
  margin-bottom: calc(var(--wordmark-h) * -0.4);
  background: url("../images/the-gradual-steep.svg") no-repeat center / contain;
}
/* The SVG carries the visual; keep the heading text for screen readers / SEO */
.fixed-title.svg h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

article {
  display: block;
}

.content .article {
  position: relative;
  z-index: 0;
  margin-top: 0;
  padding: clamp(1.5rem, 4vw, 2.8rem) clamp(1.25rem, 4vw, 3.1rem)
    clamp(1.25rem, 3vw, 1.75rem);
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 2px;
}

.date-sub {
  font-size: 1.125rem;
  color: var(--muted);
}

.article-body {
  /* 17px on small screens -> 20px on wide ones; rem-based so it still
     responds to the reader's browser font-size preference */
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.25rem);
  line-height: 1.65;
}
.article-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Post navigation / meta links */
.article-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 1rem 0 1.75rem;
}
.article-links a {
  font-size: 1.125rem;
  color: var(--ink);
}
.article-links a:hover {
  color: var(--ink-soft);
}
.article-links a.rss {
  margin-right: auto; /* keep RSS at the far left */
}

.content-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
}
.content-buttons a {
  padding: 0.15em 0.6em;
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 2px;
}
.content-buttons a:hover {
  color: var(--ink-soft);
}
.fl {
  order: 1;
  margin-right: auto; /* "more / next" on the left */
}
.fr {
  order: 2;
  margin-left: auto; /* "previous" on the right */
}

/* --------------------------------------------------------------------------
   Archive
   -------------------------------------------------------------------------- */

.fixed-title:not(.svg) h1 {
  color: var(--heading);
}

.content .archive {
  margin-top: 1rem;
  padding: 1.5rem 0.3rem;
  color: var(--ink);
}

.archive .year {
  font-family: var(--font-body);
  color: var(--muted);
  font-size: 1.5rem;
  margin-bottom: 0.45rem;
}

.archive ul {
  margin: 0 0 0.65rem 1.5rem;
  padding: 0 0 0.4rem;
  background: url("../images/grey-bar.png") repeat-y;
  list-style: none;
}
.archive ul li {
  margin-left: 0.25rem;
  padding: 0.25rem 1.5rem;
  background: url("../images/triangle.png") no-repeat 0 0.65rem;
}
.archive ul li .date {
  display: inline-block;
  width: 150px;
  color: var(--muted);
  font-size: 1.125rem;
}
.archive ul li a {
  font-family: var(--font-bold);
  font-size: 1.25rem;
  color: var(--heading);
}
.archive ul li a:hover {
  color: var(--muted);
}
.archive .rss {
  display: block;
  margin-top: 1rem;
  font-size: 1.25rem;
}

/* On narrow screens stack the date above the title rather than truncating */
@media (max-width: 480px) {
  .archive ul li .date {
    display: block;
    width: auto;
  }
}

/* --------------------------------------------------------------------------
   Comments
   -------------------------------------------------------------------------- */

.comments {
  margin-top: clamp(2.5rem, 6vw, 3.75rem);
  padding-top: clamp(1.5rem, 4vw, 2.5rem);
  border-top: 1px solid var(--card-border);
}

.comments-heading {
  font-family: var(--font-bold);
  color: var(--heading);
  margin-bottom: 0.35rem;
}

.comments-note {
  margin-top: 0;
  color: var(--muted);
  font-size: 1rem;
}

.comment-list,
.comment-replies {
  margin: 0;
  padding: 0;
  list-style: none;
}

.comment {
  margin: 1.5rem 0;
}

.comment-replies {
  margin-top: 1.25rem;
  padding-left: clamp(1rem, 4vw, 2rem);
  border-left: 2px solid var(--card-border);
}

.comment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
}
.comment-author {
  font-family: var(--font-bold);
  color: var(--heading);
}
.comment-meta time {
  color: var(--muted);
  font-size: 0.9375rem;
}

.comment-body {
  color: var(--ink);
}
.comment-body p:first-child {
  margin-top: 0;
}
.comment-body p:last-child {
  margin-bottom: 0;
}

/* giscus iframe spacing */
.comments .giscus {
  margin-top: 1.5rem;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

#about {
  margin-top: clamp(2.5rem, 6vw, 3.5rem);
}

.footer {
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.5rem) var(--gutter) clamp(1.5rem, 4vw, 2rem);
  font-size: 1.125rem;
  color: var(--light);
}
.footer a {
  color: var(--light-dim);
}
.footer a:hover {
  color: var(--light);
}

.about {
  max-width: 68ch;
  margin-bottom: clamp(2rem, 5vw, 3rem);
}
.about p a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.contact {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
}
.contact-element ul {
  margin: 0;
  padding: 0;
  line-height: 1.9;
  list-style: none;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: clamp(2.5rem, 6vw, 4rem);
  color: var(--muted);
}
.footer-bottom .back-link {
  color: var(--muted);
}

.no-top-margin {
  margin-top: 0;
}

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */

@media (max-width: 560px) {
  header .center {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }
  header nav {
    order: 0; /* name on top, nav beneath it */
  }
}

/* --------------------------------------------------------------------------
   Legacy clearfix (templates still apply .cf); harmless with flex layouts
   -------------------------------------------------------------------------- */

.cf::before,
.cf::after {
  content: "";
  display: table;
}
.cf::after {
  clear: both;
}

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