/* App home, ported from the base repo (denismoulin.com): reset.css +
   base.css + home.css, minus the base-only project icons and Then
   grouping. Same design tokens, keep in sync with base. */

/*
  Josh's Custom CSS Reset. Thank you Josh!
  https://www.joshwcomeau.com/css/custom-css-reset/
*/

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

* {
  margin: 0;
}

body {
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
}

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

#root, #__next {
  isolation: isolate;
}

/* Color tokens, shared with the Cactus app design system
   (cactus-app/Cactus/DesignSystem.swift) */
:root {
    --c000: rgb(16, 16, 16);
    --c010: rgb(28, 28, 30);
    --c020: rgb(44, 44, 46);
    --c025: rgb(60, 60, 60);
    --c050: rgb(113, 113, 113);
    --c075: rgb(167, 167, 167);
    --c085: rgb(211, 211, 211);
    --c100: rgb(255, 255, 255);

    /* Type tokens: heading (--fh), paragraph (--fp), date/label (--fd) */
    --fh-family: "DepartureMono";
    --fh-size: 0.95rem;
    --fh-lh: 1;
    --fh-ls: 0em;
    --fh-case: uppercase;
    --fh-color: var(--c100);
    /* SF Pro Display Regular — Font Book, local only; the body rule falls
       back to system-ui (SF Pro on Apple devices) when it's not installed */
    --fp-family: "SFProDisplay-Regular";
    --fp-size: 0.85rem;
    --fp-lh: 1.7;
    --fp-ls: 0em;
    --fp-case: none;
    --fp-color: var(--c075);
    --fd-family: "DepartureMono";
    --fd-size: 0.75rem;
    --fd-lh: 1;
    --fd-ls: 0em;
    --fd-case: uppercase;
    --fd-color: var(--c050);

    /* Spacing tokens: the vertical rhythm shared by home, feed and posts */
    --sp-page: 4rem;    /* main padding */
    --sp-section: 4rem; /* between posts/sections */
    --sp-label: 2rem;   /* above and below date/label rows */
    --sp-h1: 2rem;      /* below a post heading */
    --sp-block: 1rem;   /* below paragraphs, media and lists */
    --sp-item: 0.75rem; /* between home line items */
}

/* Mobile spacing: same tokens, tighter rhythm (breakpoint matches main.css) */
@media (max-width: 31.25rem) {
    :root {
        --sp-page: 1.5rem;
        --sp-section: 3rem;
        --sp-label: 1.5rem;
        --sp-h1: 1.5rem;
        --sp-block: 1.5rem;
        --sp-item: 0.5rem;
    }
}

@font-face {
    font-family: "DepartureMono";
    src:
        url("/fonts/DepartureMono-Regular.woff2") format("woff2"),
        url("/fonts/DepartureMono-Regular.woff") format("woff");
    font-display: swap;
}

/* Safari 26 ignores theme-color. It tints its toolbar from the
   background-color of a position: fixed box that touches the top edge and
   spans at least 80% of the viewport, and only falls back to the page
   background when that heuristic finds nothing, which on macOS Tahoe it
   does not do reliably. This strip is that box: same color as the page, so
   it is invisible, and it reaches 128px above the viewport so the sample
   lands on it whether WebKit reads the top edge or the inset under the
   toolbar. Keep z-index at 0 or above, WebKit skips negative ones, and
   never opacity 0, that disqualifies it too. */
.toolbar-tint {
    position: fixed;
    top: -128px;
    left: 0;
    right: 0;
    height: 136px;
    background-color: var(--c000);
    z-index: 0;
    pointer-events: none;
}

/* The root carries the page color too, so the canvas and the overscroll
   area under the toolbar read the same token */
html {
    background-color: var(--c000);
}

body {
    font-family: var(--fp-family), system-ui;
    font-size: var(--fp-size);
    line-height: var(--fp-lh);
    letter-spacing: var(--fp-ls);
    text-transform: var(--fp-case);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--fp-color);
    background: var(--c000);
    margin: 0;
    padding: 0;
}

i {
    display: inline-block;
    font-style: normal;
    margin: var(--sp-label) 0rem;
    font-family: var(--fd-family), system-ui;
    font-size: var(--fd-size);
    line-height: var(--fd-lh);
    letter-spacing: var(--fd-ls);
    text-transform: var(--fd-case);
    color: var(--fd-color);
}

a:link,
a:visited,
a:hover {
    color: inherit;
    text-decoration: none;
    /* follows the link's own color, so dimmed rows dim their underlines too */
    border-bottom: 0.5px solid color-mix(in srgb, currentColor 30%, transparent);
}

/* Utility links (Back, More, nav) wear the date/label text style and
   keep the standard link underline */
a.label-link {
    font-family: var(--fd-family), system-ui;
    font-size: var(--fd-size);
    line-height: var(--fd-lh);
    letter-spacing: var(--fd-ls);
    text-transform: var(--fd-case);
    color: var(--fd-color);
}

a.label-link:hover {
    color: var(--c100);
}

/* Home type tokens: label (--hl), line-item title (--ht) and description
   (--hd). Line items rest at the dim color token and return to their own
   color on hover. */
:root {
    --hl-family: "DepartureMono";
    --hl-size: 0.75rem;
    --hl-lh: 1;
    --hl-ls: 0em;
    --hl-case: uppercase;
    --hl-color: var(--c100);
    --ht-family: "DepartureMono";
    --ht-size: 0.75rem;
    --ht-lh: 1.6;
    --ht-ls: 0em;
    --ht-case: uppercase;
    --ht-color: var(--c100);
    --hd-family: "DepartureMono";
    --hd-size: 0.75rem;
    --hd-lh: 1.6;
    --hd-ls: 0em;
    --hd-case: uppercase;
    --hd-color: var(--c085);
    --hitem-dim-color: var(--c050);
}

body {
    color: var(--c100);
}

main i {
    font-family: var(--hl-family), system-ui;
    font-size: var(--hl-size);
    line-height: var(--hl-lh);
    letter-spacing: var(--hl-ls);
    text-transform: var(--hl-case);
    color: var(--hl-color);
}

main li a.title {
    font-family: var(--ht-family), system-ui;
    font-size: var(--ht-size);
    line-height: var(--ht-lh);
    letter-spacing: var(--ht-ls);
    text-transform: var(--ht-case);
}

main li a.desc {
    font-family: var(--hd-family), system-ui;
    font-size: var(--hd-size);
    line-height: var(--hd-lh);
    letter-spacing: var(--hd-ls);
    text-transform: var(--hd-case);
}

/* tuned colors show at full strength on hover; the rest state uses the dim
   color token */
main ul:hover li:hover a.title {
    color: var(--ht-color);
}

main ul:hover li:hover a.desc {
    color: var(--hd-color);
}

main {
    min-height: 100vh;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* On small screens the sections start at the top with the shared page
   padding, like the posts and post pages. The 100vh floor goes with the
   centering: on phones vh is the toolbars-retracted height, so it holds
   main taller than the visible viewport and scrolls the page by the height
   of the browser chrome, for content that already fits. */
@media (max-width: 31.25rem) {
    main {
        min-height: auto;
        justify-content: flex-start;
        padding: var(--sp-page);
    }
}

section {
    width: 100%;
    max-width: 30rem;
}

/* Doubles the gap between the two home sections: the label's own top
   margin provides the first half, this the second */
section + section {
    margin-top: var(--sp-label);
}

/* Bio paragraphs read as post body text: the paragraph type tokens */
.bio p {
    font-family: var(--fp-family), system-ui;
    font-size: var(--fp-size);
    line-height: var(--fp-lh);
    letter-spacing: var(--fp-ls);
    text-transform: var(--fp-case);
    color: var(--fp-color);
    margin: 0 0 var(--sp-block);
}

.bio p:last-child {
    margin-bottom: 0;
}

/* Section headings: a toggle on the left (Now / Then, Picks / All posts)
   and, for Posts, More on the right, like a line item without the dotted
   line. The row takes the label's vertical space as padding, since no <i>
   label carries its margins here; padding, unlike margin, can't collapse
   into the section's own top margin, so the gap between the two sections
   stays doubled */
section .heading {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: var(--sp-label) 0;
}

/* The toggle reads as the /posts filter row: the label type, the active
   one in the label color, the other and the slash dimmed */
section .filters {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

section .filters .sep {
    margin: 0;
    color: var(--hitem-dim-color);
}

section .filters .filter {
    padding: 0;
    background: none;
    border: none;
    border-bottom: 0.5px solid color-mix(in srgb, currentColor 30%, transparent);
    cursor: pointer;
    font-family: var(--hl-family), system-ui;
    font-size: var(--hl-size);
    line-height: var(--hl-lh);
    letter-spacing: var(--hl-ls);
    text-transform: var(--hl-case);
    color: var(--hitem-dim-color);
    transition: color ease-out 0.3s;
}

section .filters .filter:hover,
section .filters .filter.is-active {
    color: var(--hl-color);
}

section .heading a.more {
    color: var(--hitem-dim-color);
    transition: all ease-out 0.3s;
}

section .heading a.more:hover {
    color: var(--c100);
    transition: all ease-out 0.6s;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: var(--sp-item);
    transition: all ease-out 0.3s;
}

li {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    gap: 1rem;
    align-items: center;
    color: var(--hitem-dim-color);
    transition: all ease-out 0.3s;
}

/* The title is plain text and the description is the link; the
   description truncates when the line runs out of room */
li a.title {
    flex-shrink: 0;
    overflow: visible;
    text-overflow: clip;
    border-bottom: none;
}

/* follows the row's color, so it dims and brightens with it */
.dotted-line {
    flex-grow: 1;
    height: 1px;
    border-bottom: 1px dotted color-mix(in srgb, currentColor 25%, transparent);
}

ul:hover li:hover {
    cursor: default;
    color: var(--c100);
    transition: all ease-out 0.6s;
}

/* li's display: flex would otherwise outrank the hidden attribute */
li[hidden] {
    display: none;
}

li a {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* App home: section labels (the project name, Apps, Pages, Posts) sit
   in the heading where base's toggles sit, so they drop the label margins */
section .heading .name {
    margin: 0;
}
