/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

:root {
  color-scheme: light;
  --background: #d5d6db;
  --surface: #e6e7ed;
  --text: #232433;
  --muted: #565f89;
  --line: #b7b9c8;
  --accent: #34548a;
  --accent-dark: #5a4a78;
  --brand-box: #414868;
  --danger: #b42318;
  --danger-dark: #8f1d14;
  --header-background: rgba(213, 214, 219, 0.88);
  --secondary-surface: #cbccd7;
  --secondary-surface-hover: #c0c2cf;
  --input-background: #f0f1f6;
}

[data-theme="dark"] {
  color-scheme: dark;
  --background: #1a1b26;
  --surface: #24283b;
  --text: #c0caf5;
  --muted: #9aa5ce;
  --line: #3b4261;
  --accent: #7aa2f7;
  --accent-dark: #bb9af7;
  --brand-box: #414868;
  --danger: #ef4444;
  --danger-dark: #fecaca;
  --header-background: rgba(26, 27, 38, 0.9);
  --secondary-surface: #292e42;
  --secondary-surface-hover: #323852;
  --input-background: #16161e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

a {
  color: inherit;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--header-background);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-nav {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-link {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.nav-link:hover {
  text-decoration: underline;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0;
}

.link-button:hover {
  color: var(--text);
}

.theme-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 1.08rem;
  font-weight: 700;
  justify-content: center;
  line-height: 1;
  min-height: 32px;
  width: 32px;
  padding: 0;
}

.theme-toggle:hover {
  color: var(--accent-dark);
}

.theme-icon,
.nav-icon {
  fill: none;
  height: 18px;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.nav-icon-link {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  justify-content: center;
  min-height: 32px;
  text-decoration: none;
  width: 32px;
}

.nav-icon-link:hover {
  color: var(--accent-dark);
}

.nav-icon {
  fill: currentcolor;
  stroke: none;
}

[data-theme="dark"] [data-theme-moon],
[data-theme="light"] [data-theme-sun] {
  display: none;
}

.brand {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  font-size: 1rem;
  gap: 10px;
  font-weight: 800;
  text-decoration: none;
}

.brand:hover {
  color: var(--accent-dark);
}

.brand-mark {
  align-items: center;
  background: var(--brand-box);
  border-radius: 7px;
  color: #ffffff;
  display: inline-flex;
  font-size: 0.88rem;
  font-weight: 800;
  height: 28px;
  justify-content: center;
  line-height: 1;
  width: 28px;
}

.nav-action,
.button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #111827;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

.nav-action:hover,
.button:hover {
  background: var(--accent-dark);
}

.site-nav .nav-action {
  background: transparent;
  color: var(--accent-dark);
  min-height: auto;
  padding: 0;
}

.site-nav .nav-action:hover {
  background: transparent;
  text-decoration: underline;
}

.button-secondary {
  background: var(--secondary-surface);
  color: var(--text);
}

.button-secondary:hover {
  background: var(--secondary-surface-hover);
}

.button-danger {
  background: var(--danger);
}

.button-danger:hover {
  background: var(--danger-dark);
}

.site-main {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 64px;
}

.hero {
  max-width: 860px;
  padding: 20px 0 34px;
}

.terminal-card {
  background: var(--input-background);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  margin-top: 22px;
  max-width: 760px;
  overflow: hidden;
}

.terminal-line {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 10px;
  min-height: 46px;
  padding: 0 16px;
}

.terminal-line code {
  color: var(--accent);
  font-size: 0.96rem;
}

.terminal-prompt {
  color: var(--accent-dark);
  font-weight: 800;
}

.terminal-output {
  background: color-mix(in srgb, var(--surface) 34%, transparent);
  padding: 16px;
}

.terminal-output p {
  margin: 0;
}

.terminal-cursor {
  animation: cursor-blink 1s steps(1, end) infinite;
  background: var(--accent-dark);
  display: inline-block;
  height: 1.15em;
  margin-left: 7px;
  vertical-align: -0.18em;
  width: 8px;
}

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

.eyebrow,
.post-date {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.hero h1,
.post-detail h1,
.form-page h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.08;
  margin: 0;
}

.hero-copy {
  color: var(--muted);
  font-size: 1.02rem;
  max-width: 760px;
  margin: 16px 0 0;
}

.posts-section {
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.section-header h2,
.empty-state h2,
.form-errors h2 {
  margin: 0;
}

.section-header h2 {
  color: var(--accent-dark);
  font-size: 1rem;
}

.archive-layout {
  align-items: start;
  display: grid;
  gap: 56px;
  grid-template-columns: minmax(0, 1fr) 180px;
}

.archive-month {
  scroll-margin-top: 86px;
}

.archive-month + .archive-month {
  margin-top: 46px;
}

.archive-month h2 {
  border-bottom: 1px solid var(--line);
  font-size: 1.68rem;
  line-height: 1.2;
  margin: 0;
  padding-bottom: 8px;
}

.archive-sidebar {
  color: var(--muted);
  position: sticky;
  top: 86px;
}

.archive-sidebar h2 {
  color: var(--text);
  font-size: 0.9rem;
  margin: 0 0 12px;
}

.archive-sidebar nav {
  display: grid;
  gap: 8px;
}

.archive-sidebar a {
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.archive-sidebar a:hover {
  color: var(--accent-dark);
}

.about-page {
  max-width: 820px;
}

.page-heading {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 24px;
}

.about-page h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.08;
  margin: 0;
}

.about-copy {
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 760px;
}

.about-copy p {
  margin: 0 0 18px;
}

.post-list {
  display: block;
}

.post-card,
.empty-state,
.post-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 24px;
}

.post-card {
  background: transparent;
  border-width: 0 0 1px;
  border-radius: 0;
  display: flex;
  gap: 14px;
  padding: 18px 0;
}

.post-card::before {
  background: var(--accent-dark);
  content: "";
  flex: 0 0 auto;
  height: 9px;
  margin-top: 7px;
  transform: rotate(45deg);
  width: 9px;
}

.post-card-content {
  min-width: 0;
}

.post-card h3 {
  font-size: 1.12rem;
  line-height: 1.25;
  margin: 0 0 6px;
}

.post-card h3 a,
.text-link {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.post-card h3 a:hover,
.text-link:hover {
  text-decoration: underline;
}

.post-card p,
.empty-state p,
.post-summary {
  color: var(--muted);
  margin: 0;
}

.post-detail {
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 0 0;
}

.post-detail h1 {
  margin: 16px 0 18px;
}

.post-summary {
  font-size: 1.08rem;
  margin-bottom: 30px;
  max-width: 820px;
}

.post-body {
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 1.08rem;
  margin-top: 30px;
  max-width: 860px;
  padding-top: 30px;
}

.markdown-body p {
  margin: 0 0 18px;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  line-height: 1.18;
  margin: 28px 0 12px;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body h1 {
  font-size: 2rem;
}

.markdown-body h2 {
  font-size: 1.6rem;
}

.markdown-body h3 {
  font-size: 1.28rem;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 18px;
  padding-left: 24px;
}

.markdown-body blockquote {
  border-left: 4px solid var(--accent);
  color: var(--muted);
  margin: 0 0 18px;
  padding: 4px 0 4px 16px;
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

.markdown-body code {
  background: var(--secondary-surface);
  border-radius: 6px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  padding: 2px 5px;
}

.markdown-body pre {
  background: var(--secondary-surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
  padding: 16px;
}

.markdown-body pre code {
  background: transparent;
  border-radius: 0;
  display: block;
  padding: 0;
}

.markdown-body a {
  color: var(--accent-dark);
  font-weight: 800;
}

.markdown-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 28px 0;
}

.markdown-body table {
  border-collapse: collapse;
  display: block;
  margin: 0 0 18px;
  overflow-x: auto;
  width: 100%;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
}

.markdown-body th {
  background: var(--secondary-surface);
}

.form-page {
  max-width: 760px;
}

.auth-page {
  max-width: 640px;
}

.auth-copy {
  color: var(--muted);
  font-size: 1.08rem;
  margin: 18px 0 24px;
}

.post-form {
  margin-top: 24px;
}

.markdown-editor {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
}

.markdown-input {
  margin-bottom: 0;
}

.markdown-input textarea {
  min-height: 440px;
}

.markdown-preview {
  background: var(--input-background);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 440px;
  overflow: hidden;
}

.markdown-preview-header {
  background: var(--secondary-surface);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 10px 14px;
  text-transform: uppercase;
}

.markdown-preview .markdown-body {
  max-height: 560px;
  overflow: auto;
  padding: 18px;
}

.markdown-empty {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.field label {
  font-weight: 800;
}

.field input,
.field textarea {
  background: var(--input-background);
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 12px 14px;
}

.field textarea {
  resize: vertical;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
}

.actions form {
  margin: 0;
}

.security-key-list {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.security-key-card {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 20px;
}

.security-key-card h2 {
  font-size: 1.1rem;
  margin: 0 0 6px;
}

.security-key-card p {
  color: var(--muted);
  margin: 0;
}

.flash,
.form-errors {
  border-radius: 8px;
  margin: 0 0 18px;
  padding: 14px 16px;
}

.flash-notice {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent-dark);
}

.flash-alert,
.form-errors {
  background: #fff1f0;
  color: var(--danger-dark);
}

@media (max-width: 640px) {
  .site-main {
    padding: 36px 0;
  }

  .site-nav {
    align-items: center;
    flex-direction: row;
  }

  .nav-links {
    align-items: center;
    flex-direction: row;
    width: auto;
  }

  .nav-action,
  .button {
    width: 100%;
  }

  .security-key-card {
    align-items: stretch;
    flex-direction: column;
  }

  .archive-layout {
    gap: 28px;
    grid-template-columns: 1fr;
  }

  .archive-sidebar {
    border-top: 1px solid var(--line);
    padding-top: 18px;
    position: static;
  }

  .post-card,
  .empty-state,
  .post-form {
    padding: 18px;
  }

  .post-card {
    gap: 12px;
    padding: 16px 0;
  }

  .post-card::before {
    height: 8px;
    margin-top: 7px;
    width: 8px;
  }

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

  .markdown-input textarea,
  .markdown-preview {
    min-height: 320px;
  }
}
