/* dogear — one hand-written stylesheet. Monospace, one accent, light and dark. */
:root {
  --paper: #fbfaf7;
  --ink: #1b1b1a;
  --muted: #7a7873;
  --rule: #e6e3dc;
  --accent: #c2410c;
  --desk: #efece5;
  --fold: #1b1b1a;
  --focus: #c2410c;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121211;
    --ink: #e7e5df;
    --muted: #8b8984;
    --rule: #262624;
    --accent: #fb923c;
    --desk: #1c1c1a;
    --fold: #e7e5df;
    --focus: #fb923c;
  }
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font:
    14px/1.6 ui-monospace,
    'SF Mono',
    SFMono-Regular,
    Menlo,
    Consolas,
    'Liberation Mono',
    monospace;
}
a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px;
}

/* brand mark: a single-line dog-ear pinned to the page's top right */
.dogear {
  position: absolute;
  top: 0;
  right: 0;
  width: 48px;
  height: 48px;
  display: block;
  color: var(--fold);
  transition:
    width 150ms ease,
    height 150ms ease;
  z-index: 30;
}
.dogear svg {
  width: 100%;
  height: 100%;
  display: block;
}
/* the cut-away corner shows the desk behind the page; the flap is one stroke */
.dogear .cut {
  fill: var(--desk);
}
.dogear .flap {
  fill: transparent;
  transition: fill 150ms ease;
}
.dogear:hover,
.dogear:focus-visible {
  width: 60px;
  height: 60px;
  text-decoration: none;
}
.dogear:hover .flap,
.dogear:focus-visible .flap {
  fill: var(--paper);
}
.dogear:focus-visible {
  outline-offset: -4px;
}
@media (prefers-reduced-motion: reduce) {
  .dogear,
  .dogear .flap {
    transition: none;
  }
}

header.top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 20px;
  padding: 28px 56px 28px 0;
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  font-weight: 700;
  letter-spacing: -0.02em;
}
nav.main {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  color: var(--muted);
}
nav.main a[aria-current='page'] {
  color: var(--ink);
}
nav.main .me {
  margin-left: auto;
}

main {
  padding: 20px 0 48px;
  min-height: 60vh;
}
footer {
  border-top: 1px solid var(--rule);
  padding: 20px 0 40px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 12px;
}

h1 {
  font-size: 16px;
  margin: 0 0 4px;
  font-weight: 700;
}
h2 {
  font-size: 14px;
  margin: 32px 0 8px;
  font-weight: 700;
}
p {
  margin: 0 0 12px;
}
.muted,
.domain,
.meta {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.lede {
  color: var(--muted);
  margin-bottom: 20px;
}
hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 24px 0;
}

/* chips and tabs */
.chips,
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0 0 16px;
  color: var(--muted);
}
.chips a::before {
  content: '#';
  opacity: 0.6;
}
.tabs a[aria-current='page'],
.chips a[aria-current='page'] {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* feed */
.feed {
  list-style: none;
  margin: 0;
  padding: 0;
}
.row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}
.row:last-child {
  border-bottom: 0;
}
.title {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.blurb {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}
.meta {
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 0 10px;
  margin-top: 2px;
}
.label {
  font-size: 11px;
  border: 1px solid var(--rule);
  padding: 0 5px;
  border-radius: 2px;
  color: var(--muted);
}
.label.warn {
  color: var(--accent);
  border-color: var(--accent);
}
.note {
  margin: 6px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--accent);
}
.more {
  padding: 16px 0;
  color: var(--muted);
}

/* vote column */
.vote {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.vote form {
  display: contents;
}
.vote button {
  appearance: none;
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  width: 44px;
  height: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.vote button:hover {
  color: var(--ink);
}
.vote button[aria-pressed='true'] {
  color: var(--accent);
}
.vote .count {
  font-size: 12px;
  min-height: 18px;
}

/* forms */
form.stack {
  display: grid;
  gap: 14px;
  max-width: 520px;
}
label {
  display: grid;
  gap: 4px;
}
label > span {
  color: var(--muted);
  font-size: 12px;
}
input[type='text'],
input[type='url'],
input[type='search'],
select,
textarea {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 8px 10px;
  width: 100%;
  min-height: 44px;
}
textarea {
  min-height: 76px;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--ink);
  outline: none;
}
.btn,
button.btn {
  appearance: none;
  font: inherit;
  cursor: pointer;
  display: inline-block;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 8px 14px;
  border-radius: 2px;
  min-height: 44px;
  line-height: 26px;
}
.btn.ghost,
button.ghost {
  background: transparent;
  color: var(--ink);
}
.btn.danger {
  border-color: var(--accent);
  background: transparent;
  color: var(--accent);
}
.btn:hover {
  text-decoration: none;
  opacity: 0.9;
}
button.link {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
button.link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.inline {
  display: inline;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}
.flash {
  border: 1px solid var(--rule);
  border-left: 2px solid var(--accent);
  padding: 10px 12px;
  margin: 0 0 16px;
}
.error {
  color: var(--accent);
}
.saved {
  color: var(--accent);
}
.save-menu {
  margin: 8px 0 0;
  padding: 12px;
  border: 1px solid var(--rule);
  display: grid;
  gap: 10px;
  max-width: 480px;
}

/* code & tables */
code,
pre {
  font: inherit;
}
pre {
  background: var(--desk);
  padding: 12px;
  overflow-x: auto;
  border-radius: 2px;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 12px;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}
th,
td {
  text-align: left;
  padding: 6px 8px 6px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 400;
}
dl.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 8px 0 12px;
}
dl.kv dt {
  color: var(--muted);
}
dl.kv dd {
  margin: 0;
}
ul.plain {
  list-style: none;
  padding: 0;
  margin: 0;
}
ul.plain li {
  padding: 4px 0;
}
ul.tree {
  padding-left: 18px;
  margin: 4px 0 12px;
  color: var(--muted);
}
ul.tree a {
  color: var(--ink);
}

/* htmx indicator styles (includeIndicatorStyles is off for the CSP) */
.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

.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;
}
@media (max-width: 520px) {
  .wrap {
    padding: 0 16px;
  }
  header.top {
    padding-top: 20px;
    padding-bottom: 20px;
  }
  nav.main .me {
    margin-left: 0;
  }
}

/* compact layout: one dense line per item, no blurbs */
.feed.compact .row {
  grid-template-columns: 64px 1fr;
  gap: 8px;
  padding: 5px 0;
  align-items: baseline;
}
.feed.compact .vote {
  flex-direction: row;
  gap: 2px;
}
.feed.compact .vote button {
  width: 18px;
  height: 22px;
  font-size: 11px;
}
.feed.compact .vote .count {
  min-width: 18px;
  text-align: center;
}
.feed.compact .row > div:last-child {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 10px;
  min-width: 0;
}
.feed.compact .meta {
  margin: 0;
}
.feed.compact .blurb,
.feed.compact .note {
  display: none;
}
.feed.compact .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* lists index */
h2.group {
  margin-top: 28px;
}
table.index td.num {
  text-align: right;
  color: var(--muted);
  width: 4em;
}
table.index td:nth-child(2) {
  font-size: 11px;
}
ul.index li {
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
}
@media (max-width: 520px) {
  table.index td:nth-child(2) {
    display: none;
  }
}

/* infinite scroll: an invisible trigger a dozen rows before the end, and
   a no-JS "more" link that only shows on the last page loaded */
.feed .sentinel {
  height: 1px;
  list-style: none;
}
.feed .more:not(:last-child) {
  display: none;
}

.meta a.out {
  color: var(--accent);
}

/* ⌘K search dialog */
kbd {
  font: inherit;
  font-size: 10px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0 3px;
  color: var(--muted);
}
dialog.cmdk {
  width: min(640px, calc(100vw - 32px));
  max-height: 80vh;
  margin: 12vh auto auto;
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
}
dialog.cmdk::backdrop {
  background: rgb(0 0 0 / 35%);
}
dialog.cmdk input[type='search'] {
  font-size: 16px;
}
dialog.cmdk #cmdk-results {
  max-height: 55vh;
  overflow-y: auto;
  margin-top: 8px;
}
dialog.cmdk .small {
  margin: 8px 0 0;
}

/* thumbnails: served from /img/{id}, never third-party */
.row.has-thumb {
  grid-template-columns: 44px 1fr 120px;
}
.thumb img {
  display: block;
  width: 120px;
  height: 68px;
  object-fit: cover;
  background: var(--desk);
  border: 1px solid var(--rule);
  border-radius: 2px;
}
.hero img {
  /* a fixed 2:1 box (GitHub cards are 2:1) so the image can't shift layout */
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  aspect-ratio: 2 / 1;
  object-fit: cover;
  background: var(--desk);
  border: 1px solid var(--rule);
  border-radius: 2px;
  margin: 0 0 16px;
}
.feed.single .thumb,
.feed.compact .thumb {
  display: none;
}
.feed.single .row.has-thumb,
.feed.compact .row.has-thumb {
  grid-template-columns: 44px 1fr;
}
.feed.compact .row.has-thumb {
  grid-template-columns: 64px 1fr;
}
@media (max-width: 520px) {
  .row.has-thumb {
    grid-template-columns: 44px 1fr 72px;
  }
  .thumb img {
    width: 72px;
    height: 48px;
  }
}

details.transcript {
  margin: 12px 0;
}
details.transcript summary {
  cursor: pointer;
  color: var(--muted);
}
details.transcript p {
  max-height: 360px;
  overflow-y: auto;
  font-size: 12px;
  border-left: 2px solid var(--rule);
  padding-left: 10px;
}

/* header stays reachable on long feeds */
header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  padding-top: 18px;
  padding-bottom: 14px;
  justify-content: space-between;
}
nav.main {
  margin-left: auto;
  align-items: baseline;
}
nav.main .post {
  color: var(--accent);
}

/* breadcrumbs */
.crumbs {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}
.crumbs a {
  color: var(--muted);
}

/* one-row, horizontally scrolling chips */
.chips.scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
  padding-bottom: 2px;
  mask-image: linear-gradient(to right, #000 90%, transparent);
}
.chips.scroll::-webkit-scrollbar {
  display: none;
}
.chips .all::before {
  content: none;
}

/* feed toolbar: sort on the left, kind and layout on the right */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 8px 0 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}
.toolbar-end {
  display: flex;
  align-items: baseline;
  gap: 16px;
}
.seg {
  display: flex;
  gap: 14px;
  color: var(--muted);
}
.seg a[aria-current='page'] {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.seg.view {
  font-size: 12px;
  gap: 10px;
}

/* small disclosure menus (kind filter, save) that work without JS */
details.menu {
  position: relative;
}
details.menu > summary {
  list-style: none;
  cursor: pointer;
  color: var(--muted);
}
details.menu > summary::-webkit-details-marker {
  display: none;
}
details.menu > summary::after {
  content: ' ▾';
  font-size: 10px;
}
details.menu[open] > summary {
  color: var(--ink);
}
details.menu > nav,
details.menu > form {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 15;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 8px 12px;
  min-width: 160px;
}
details.menu > nav {
  display: grid;
  gap: 4px;
}
details.menu > nav a[aria-current='page'] {
  color: var(--accent);
}
details.menu.save > form {
  left: 0;
  right: auto;
  min-width: 300px;
  margin: 0;
}

/* item page */
.item-title {
  font-size: 20px;
  line-height: 1.3;
  margin: 4px 0 6px;
  overflow-wrap: anywhere;
}
.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 12px;
}
.item-blurb {
  font-size: 15px;
  margin: 0 0 16px;
}
.item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin: 0 0 20px;
}
.item-actions .vote form {
  display: flex;
  align-items: center;
}
.item-actions .vote button {
  width: 32px;
  height: 32px;
}
p.quote {
  border-left: 2px solid var(--rule);
  padding-left: 10px;
}
details.more {
  margin: 24px 0 0;
}
details.more > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}
details.more[open] > summary {
  margin-bottom: 12px;
}
@media (max-width: 520px) {
  header.top {
    padding-right: 52px;
    flex-wrap: nowrap;
    gap: 12px;
  }
  nav.main {
    gap: 4px 12px;
    flex-wrap: nowrap;
  }
  nav.main kbd {
    display: none;
  }
  .toolbar-end {
    gap: 12px;
  }
  details.menu.save > form {
    min-width: min(300px, calc(100vw - 32px));
  }
}

/* phones: a slightly smaller mark that always sits above the sticky header */
@media (max-width: 520px) {
  .dogear {
    width: 40px;
    height: 40px;
  }
  .dogear:hover,
  .dogear:focus-visible {
    width: 48px;
    height: 48px;
  }
  header.top {
    padding-right: 44px;
  }
}

/* on item pages the corner mark is a button that dogears the item */
.dogear-form {
  margin: 0;
}
button.dogear {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  font: inherit;
}
.dogear.on {
  color: var(--accent);
}
.dogear.on .flap {
  fill: var(--accent);
}
.dogear.on:hover .flap,
.dogear.on:focus-visible .flap {
  fill: var(--accent);
}

/* row links are spaced and tall enough to tap */
.meta {
  gap: 2px 12px;
}
.meta a,
.meta .label {
  display: inline-block;
  min-height: 24px;
  line-height: 24px;
}

/* mobile pass */
@media (max-width: 520px) {
  /* iOS zooms into inputs under 16px */
  input[type='text'],
  input[type='url'],
  input[type='search'],
  select,
  textarea {
    font-size: 16px;
  }
  /* comfortable tap targets for nav, tabs, chips, and footer links */
  nav.main a,
  .seg a,
  .chips a,
  footer a,
  footer button.link,
  details.menu > summary {
    display: inline-block;
    padding: 6px 0;
  }
  .toolbar {
    gap: 4px 12px;
  }
  /* the kind menu opens from the left edge so it stays on screen */
  details.menu > nav,
  details.menu > form {
    left: 0;
    right: auto;
    max-width: calc(100vw - 32px);
  }
  details.menu > nav a {
    padding: 8px 0;
  }
  dialog.cmdk {
    margin-top: 8px;
    max-height: calc(100dvh - 16px);
  }
  .item-actions .btn {
    flex: 1 1 100%;
    text-align: center;
  }
  .row {
    grid-template-columns: 36px 1fr;
    gap: 10px;
  }
  .vote button {
    width: 36px;
    height: 30px;
  }
}

a.hero {
  display: block;
  max-width: 480px;
}
