/* Berkeley Mono Font */
@font-face {
  font-family: 'Berkeley Mono';
  src: url('../fonts/BerkeleyMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Berkeley Mono';
  src: url('../fonts/BerkeleyMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Berkeley Mono';
  src: url('../fonts/BerkeleyMono-Oblique.woff2') format('woff2');
  font-weight: 400;
  font-style: oblique;
  font-display: swap;
}

@font-face {
  font-family: 'Berkeley Mono';
  src: url('../fonts/BerkeleyMono-Bold-Oblique.woff2') format('woff2');
  font-weight: 700;
  font-style: oblique;
  font-display: swap;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --accent: #ff3300;
  --accent-light: #ff6b4a;
  --border: #1a1a1a;
  --border-thin: #333;
  --muted: #666;
  --note-bg: #f0f0f0;
  --note-border: #ff3300;
  --max-width: 900px;
  --gap: 1.5rem;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #e0e0e0;
  --accent: #ff5522;
  --accent-light: #ff7744;
  --border: #e0e0e0;
  --border-thin: #888;
  --muted: #888;
  --note-bg: #1a1a1a;
  --note-border: #ff5522;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --fg: #e0e0e0;
    --accent: #ff5522;
    --accent-light: #ff7744;
    --border: #e0e0e0;
    --border-thin: #888;
    --muted: #888;
    --note-bg: #1a1a1a;
    --note-border: #ff5522;
  }
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Berkeley Mono', 'Courier New', monospace;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1rem;
  min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  margin-top: 2rem;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

h1 { font-size: 1.75rem; border-bottom: 2px solid var(--border); padding-bottom: 0.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
h4, h5, h6 { font-size: 1rem; }

p, ul, ol, dl, pre, table, blockquote {
  margin-bottom: 1.5rem;
}

ul, ol {
  padding-left: 2rem;
}

li {
  margin-bottom: 0.25rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
}

a:hover, a:focus {
  background: var(--accent);
  color: var(--bg);
  outline: none;
}

strong, b {
  font-weight: 700;
}

em, i {
  font-style: oblique;
}

code, kbd, samp {
  font-family: 'Berkeley Mono', monospace;
  font-size: 0.85em;
  background: var(--note-bg);
  padding: 0.1em 0.3em;
  border: 1px solid var(--border-thin);
}

pre {
  background: var(--note-bg);
  border: 2px solid var(--border);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.8rem;
}

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

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

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

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

th {
  background: var(--note-bg);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.8rem;
}

tr:nth-child(even) {
  background: var(--note-bg);
}

/* Blockquote */
blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1rem;
  font-style: oblique;
  color: var(--muted);
}

/* Admonition/Quote Box - avatar left, content right */
aside, .note, .quote-box {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin: 1.5rem 0;
}

aside img, .note img, .quote-box img,
aside .avatar, .note .avatar, .quote-box .avatar {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

aside .content, .note .content, .quote-box .content {
  flex: 1;
}

aside .name, .note .name, .quote-box .name {
  display: block;
  font-weight: 700;
  text-decoration: underline;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

aside p, .note p, .quote-box p {
  margin: 0;
  font-size: 0.9rem;
}

/* Responsive Images */
img, picture, video, canvas, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

figure {
  margin: 1.5rem 0;
}

figcaption {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.5rem;
  text-align: center;
}

/* Form Elements */
input, textarea, select, button {
  font-family: 'Berkeley Mono', monospace;
  font-size: 0.9rem;
  padding: 0.5rem;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--fg);
}

button, input[type="submit"], input[type="button"] {
  background: var(--fg);
  color: var(--bg);
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0.5rem 1rem;
}

button:hover, button:focus,
input[type="submit"]:hover, input[type="submit"]:focus {
  background: var(--accent);
  outline: none;
}

/* Focus styles for accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--fg);
  color: var(--bg);
  padding: 0.5rem 1rem;
  z-index: 1000;
}

.skip-link:focus {
  top: 1rem;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header with toggles */
header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
}

header .header-left {
  flex: 1;
  min-width: 200px;
}

header h1 {
  margin-top: 0;
}

header h1 a {
  border-bottom: none;
}

header p {
  margin-bottom: 0.5rem;
}

header nav {
  margin-top: 0.5rem;
}

header nav a {
  margin-right: 1rem;
}

/* Theme toggles */
.theme-toggles {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 2px solid var(--border);
  background: var(--note-bg);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.toggle-row label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.toggle-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Blog Styles */
.blog-list {
  margin-top: 1.5rem;
}

.blog-post-summary {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-thin);
}

.blog-post-summary h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.blog-post-summary h2 a {
  border-bottom: none;
}

.post-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.post-meta time {
  font-weight: 700;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  background: var(--note-bg);
  border: 1px solid var(--border-thin);
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  text-transform: lowercase;
}

.tag:hover {
  background: var(--accent);
  color: var(--bg);
}

.blog-post .post-meta {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-thin);
}

/* Tag list page */
.tag-list {
  list-style: none;
  padding: 0;
}

.tag-list li {
  margin-bottom: 0.75rem;
}

.tag-list .count {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Column Layout */
.columns,
.cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap, 1.5rem);
  margin-bottom: 1.5rem;
}

.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 600px) {
  .columns, .cols, .cols-2, .cols-3, .cols-4 {
    grid-template-columns: 1fr;
  }
}

.columns > *, .cols > * {
  border: 2px solid var(--border, #1a1a1a);
  padding: 1rem;
}

.cols-clean > * {
  border: none;
  padding: 0;
}

.full-width { grid-column: 1 / -1; }

.columns .columns, .cols .cols { margin-bottom: 0; }

.cols-center { align-items: center; }
.cols-start { align-items: start; }
.cols-end { align-items: end; }

@media (min-width: 800px) {
  .sidebar-layout {
    grid-template-columns: 240px 1fr;
  }
  
  .sidebar-layout > :first-child {
    position: sticky;
    top: 2rem;
    align-self: start;
  }
}
