/* Import custom fonts */
@import url("/css/fonts.css");

/* ==========================================================================
   CONFIGURATION: Design Tokens (Flexoki Color Scheme)
   https://stephango.com/flexoki
   ========================================================================== */

:root {
  /* Light Theme Colors */
  --color-bg-primary: #fffcf0;
  --color-bg-secondary: #f2f0e5;
  --color-border-subtle: #e6e4d9;
  --color-text-primary: #100f0f;
  --color-text-secondary: #6f6e69;
  --color-text-muted: #b7b5ac;
  --color-link-underline: #b7b5ac;
  --color-link-hover: #da702c;

  /* Typographic scale and fonts */
  --font-family-sans: Whitney, system-ui, -apple-system, sans-serif;
  --font-family-heading: "IBM Plex Sans", Whitney, serif;
  --font-family-mono: "CommitMono", monospace;
  
  --font-size-base: 1.125rem;
  --font-size-mobile: 1rem;
  --line-height-base: 1.4em;
}

/* Dark Theme Overrides */
html[data-theme="dark"] {
  --color-bg-primary: #100f0f;
  --color-bg-secondary: #1c1b1a;
  --color-border-subtle: #282726;
  --color-text-primary: #fffcf0;
  --color-text-secondary: #e6e4d9;
  --color-text-muted: #cecdc3;
  --color-link-underline: #575653;
  --color-link-hover: #da702c;
}

/* OS Preference Detection */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg-primary: #100f0f;
    --color-bg-secondary: #1c1b1a;
    --color-border-subtle: #282726;
    --color-text-primary: #fffcf0;
    --color-text-secondary: #e6e4d9;
    --color-text-muted: #cecdc3;
    --color-link-underline: #575653;
    --color-link-hover: #da702c;
  }
}

/* ==========================================================================
   BASE: Reset and Global Styles
   ========================================================================== */

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-family-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  margin: auto;
  max-width: 55ch;
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  display: flex;
  flex-direction: column;
}

@media (max-width: 45rem) {
  body {
    font-size: var(--font-size-mobile);
    max-width: 90%;
    padding: 0 1rem;
  }
}

main {
  flex: 1;
}

/* Typography */

h1, h2, h3, h4, h5 {
  font-family: var(--font-family-heading);
  font-weight: normal;
}

h1 {
  font-size: 2rem;
}

h2, h3, h4, h5 {
  font-size: 1.5rem;
}

p {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Links */

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--color-link-underline);
}

a:hover {
  color: var(--color-link-hover);
  text-decoration-color: inherit;
}

/* Media Elements */

img,
iframe,
video {
  width: 100%;
  height: auto;
}

figure {
  width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

figure img {
  width: 100%;
  height: auto;
  display: block;
}

figcaption {
  text-align: center;
  margin-top: 0.5rem;
  font-size: 85%;
  color: var(--color-text-secondary);
}

/* Data Tables */

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  font-weight: bold;
  background-color: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-text-muted);
  padding: 6px;
  text-align: left;
}

tbody td {
  border-bottom: 1px solid var(--color-bg-secondary);
  padding: 6px;
}

tbody tr:hover {
  background-color: var(--color-bg-secondary);
}

/* Blockquotes and Marks */

blockquote {
  margin: 0;
  padding: 0 1.5rem;
  border-left: 2px solid var(--color-text-muted);
}

mark {
  color: var(--color-text-primary);
  background-color: var(--color-bg-secondary);
  margin: 0;
  border-radius: 2px;
}

/* ==========================================================================
   COMPONENTS: Reusable UI Elements
   ========================================================================== */

/* Navbar Component */

.navbar {
  font-family: var(--font-family-heading);
  font-size: 1.313rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-text-muted);
  margin-bottom: 1rem;
}

.navbar__left,
.navbar__right {
  display: flex;
  align-items: center;
}

.navbar__right a {
  margin-left: 1rem;
}

.navbar a {
  text-decoration: none;
}

/* Theme Toggle Component */

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem;
  margin-left: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: background-color 0.2s;
  color: var(--color-text-secondary);
}

.theme-toggle:hover {
  background-color: var(--color-bg-secondary);
  color: var(--color-text-primary);
}

.theme-toggle .icon svg {
  width: 1.2rem;
  height: 1.2rem;
  stroke-width: 1.5px;
}

/* Icon Component */

.icon svg {
  height: 1em;
  width: 1em;
  vertical-align: middle;
  fill: currentColor;
}

/* Code and Keyboard Input */

pre {
  background-color: var(--color-bg-secondary);
  padding: 10px;
  overflow: auto;
  border-radius: 5px;
  border: solid 1px var(--color-border-subtle);
  line-height: 1.3;
  font-family: var(--font-family-mono);
}

code,
kbd {
  background-color: var(--color-bg-secondary);
  padding: 0.1em 0.2em;
  margin: 0;
  border-radius: 2px;
  font-size: 80%;
  border: solid 1px var(--color-border-subtle);
  font-family: var(--font-family-mono);
}

pre code {
  border: none;
  background: none;
}

/* ==========================================================================
   LAYOUT: Page-Specific Sections
   ========================================================================== */

/* List Items (Post/Notes Listings) */

.list-items {
  list-style-type: none;
  margin: 0;
  padding: 0;
  padding-top: 2rem;
}

.list-items__link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px;
  text-decoration: none;
}

.list-items__link:hover {
  background-color: var(--color-bg-secondary);
}

.list-items__date {
  font-size: 90%;
  color: var(--color-text-secondary);
}

/* Article Metadata */

.article-meta h1 {
  margin-top: 1.75rem;
  margin-bottom: 0;
}

.article-meta__date {
  font-size: 90%;
  color: var(--color-text-secondary);
  margin-top: 0;
  margin-bottom: 1rem;
}

/* Notes Section Styles */

.note {
  margin-top: 2rem;
}

.note__footer {
  color: var(--color-text-secondary);
  font-size: 80%;
  margin: 1rem 0 2rem 0;
}

.note__divider {
  border: none;
  border-top: 3px dotted var(--color-text-muted);
  margin: 2rem 0;
}

.notes:last-of-type .note__divider {
  display: none;
}

/* Footer Component */

footer {
  padding-bottom: 1rem;
}

.footer__content {
  display: flex;
  justify-content: space-between;
  padding: 1rem 0;
  border-top: 1px solid var(--color-text-muted);
  margin-top: 1rem;
  font-size: 1rem;
  color: var(--color-text-primary);
}

@media (max-width: 45rem) {
  .footer__content {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
  }
}

.footer__rss-link {
  text-decoration: none;
}

.footer__heart svg {
  vertical-align: middle;
  margin-left: 0.1rem;
  fill: currentColor;
}

/* Error (404) Page */

.error-page {
  text-align: center;
  padding-top: 4rem;
}

.error-page h1 {
  font-size: 4rem;
  margin-bottom: 1rem;
}