/* Reset all the things!
Modern reset: https://piccalil.li/blog/a-more-modern-css-reset/ */

/* Box sizing rules */

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

/* Prevent font size inflation */

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

/* Remove default margin in favour of better control in authored CSS */

body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin-block: 0;
}

/* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */

ul[role='list'],
ol[role='list'] {
  list-style: none;
}

/* Set core body defaults */

body {
  min-height: 100vh;
  line-height: 1.5;
}

/* Set shorter line heights on headings and interactive elements */

h1,
h2,
h3,
h4,
button,
input,
label {
  line-height: 1.1;
}

/* Balance text wrapping on headings */

h1,
h2,
h3,
h4 {
  text-wrap: balance;
}

/* A elements that don't have a class get default styles */

a:not([class]) {
  text-decoration-skip-ink: auto;
  color: currentColor;
}

/* Make images easier to work with */

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

/* Inherit fonts for inputs and buttons */

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

/* Make sure textareas without a rows attribute are not tiny */

textarea:not([rows]) {
  min-height: 10em;
}

/* Anything that has been anchored to should have extra scroll margin */

:target {
  scroll-margin-block: 5ex;
}

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

@font-face {
  font-family: 'Satoshi';
  src: url('/fonts/Satoshi-Italic.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
  font-style: italic;
}

@font-face {
  font-family: 'Satoshi';
  src: url('/fonts/Satoshi-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
  font-style: normal;
}

@font-face {
  font-family: 'Satoshi';
  src: url('/fonts/Satoshi-MediumItalic.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
  font-style: italic;
}

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

@font-face {
  font-family: 'Satoshi';
  src: url('/fonts/Satoshi-Black.woff2') format('woff2');
  font-weight: 900;
  font-display: swap;
  font-style: normal;
}

@font-face {
  font-display: swap;
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  src: url('/fonts/dm-mono-v14-latin-500.woff2') format('woff2');
}

:root {
  --color-dark: #171406;
  --color-dark-glare: #2d2816;
  --color-mid: #ABA9A2;
  --color-light: #ffffff;
  --color-primary: #fccd26;
  --space-xs: clamp(0.4375rem, 0.42rem + 0.10vw, 0.5rem);
  --space-s: clamp(0.875rem, 0.83rem + 0.20vw, 1rem);
  --space-m: clamp(1.3125rem, 1.25rem + 0.29vw, 1.5rem);
  --space-l: clamp(2.1875rem, 2.09rem + 0.49vw, 2.5rem);
  --space-xl: clamp(3.0625rem, 2.92rem + 0.69vw, 3.5rem);
  --space-2xl: clamp(3.5rem, 3.34rem + 0.78vw, 4rem);
  --space-3xl: clamp(4.375rem, 4.17rem + 0.98vw, 5rem);
  --space-4xl: clamp(6.5625rem, 6.26rem + 1.47vw, 7.5rem);
  --space-xs-l: clamp(0.4375rem, -0.23rem + 3.24vw, 2.5rem);
  --space-m-l: clamp(1.3125rem, 0.93rem + 1.86vw, 2.5rem);
  --space-2xl-4xl: clamp(3.5rem, 2.21rem + 6.27vw, 7.5rem);
  --size-step-000: clamp(0.740625rem, 0.73rem + 0.06vw, 0.78125rem);
  --size-step-00: clamp(0.833125rem, 0.80rem + 0.16vw, 0.9375rem);
  --size-step-0: clamp(0.9375rem, 0.88rem + 0.29vw, 1.125rem);
  --size-step-1: clamp(1.055rem, 0.96rem + 0.46vw, 1.35rem);
  --size-step-2: clamp(1.18625rem, 1.05rem + 0.68vw, 1.62rem);
  --size-step-3: clamp(1.335rem, 1.14rem + 0.95vw, 1.94375rem);
  --size-step-4: clamp(1.501875rem, 1.23rem + 1.30vw, 2.3325rem);
  --size-step-5: clamp(1.689375rem, 1.33rem + 1.74vw, 2.799375rem);
  --size-step-6: clamp(1.900625rem, 1.43rem + 2.29vw, 3.359375rem);
  --size-step-7: clamp(2.138125rem, 1.53rem + 2.97vw, 4.03125rem);
  --size-step-8: clamp(2.405625rem, 1.62rem + 3.81vw, 4.8375rem);
  --size-step-9: clamp(2.70625rem, 1.70rem + 4.86vw, 5.805rem);
  --size-step-10: clamp(3.03125rem, 1.76rem + 6.17vw, 6.965625rem);
  --size-step-11: clamp(3.78875rem, 1.63rem + 10.45vw, 10.448125rem);
  --size-step-12: clamp(3.78875rem, 0.36rem + 16.61vw, 14.375rem);
  --leading-micro: 0.85;
  --leading-flat: 1;
  --leading-fine: 1.2;
  --leading-standard: 1.4;
  --leading-loose: 1.7;
  --font-base: Satoshi,Inter,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;
  --font-mono: DM Mono,monospace;
  --font-regular: 400;
  --font-medium: 500;
  --font-bold: 700;
  --font-black: 900;
  --gutter: var(--space-m-l);
  --transition-base: 250ms ease;
  --transition-movement: 200ms linear;
  --transition-fade: 300ms ease;
  --transition-bounce: 500ms cubic-bezier(0.5, 0.05, 0.2, 1.5);
  --stroke: 1px dashed var(--color-mid);
  --stroke-solid: 1px solid var(--color-mid);
  --radius-s: 0.2rem;
  --radius-m: 0.75rem;
  --radius-l: 2.5rem;
  --uppercase-kerning: 0.04ch;
  --wrapper-max-width: 700px;
}

/* 
  Global styles 

  Low-specificity, global styles that apply to the whole 
  project: https://cube.fyi/css.html
*/

body {
  /* background: var(--color-dark); */
  /* color: var(--color-primary); */
  font-size: var(--size-step-1);
  font-family: var(--font-base);
  line-height: var(--leading-standard);
  font-size-adjust: from-font;
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* Full height of the viewport */
}

main {
  flex-grow: 1;
}

:is(h1, h2, h3, h4) {
  line-height: var(--leading-fine);
  text-wrap: balance;
}

h1 {
  font-size: var(--size-step-6);
  max-width: 20ch;
}

h2 {
  font-size: var(--size-step-5);
  max-width: 35ch;
}

h3 {
  font-size: var(--size-step-4);
  max-width: 35ch;
}

:is(h4, h5, h6) {
  font-size: var(--size-step-3);
}

small {
  font-size: var(--size-step-0);
}

ins {
  text-decoration: none;
  background: var(--color-primary);
  color: var(--color-dark);
  padding-inline: 0.3em;
}

:is(code, kbd, samp) {
  font-family: var(--font-mono);
  padding: 0.2em 0.2em 0.05em 0.2em;
  hyphens: none;
  tab-size: 2;
  text-align: left;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  box-decoration-break: clone;
}

/* This is quite a new property, so we want code styles to at least, not be huge or tiny */

@supports not (font-size-adjust: from-font) {
  :is(code, kbd, samp) {
    font-size: 0.8em;
  }
}

pre:has(code) {
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
}

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

kbd {
  border: 1px solid;
  padding-block-end: 0.1em;
}

var {
  font-style: normal;
  font-weight: var(--font-medium);
}

q {
  font-style: italic;
}

ul:not([class]) {
  padding-inline-start: 1.7ch;
  list-style-type: disc;
}

ul:not([class]) > li {
  padding-inline-start: var(--space-xs);
}

:is(ol, ul):not([class]) li + * {
  margin-block-start: var(--flow-space, var(--space-xs));
}

ul ::marker {
  font-size: 0.8lh;
}

ol ::marker {
  font-size: 1em;
  font-weight: var(--font-bold);
}

/* Lists with classes and roles will be out of standard flow, so remove the default spacing */

[role='list'][class],
[role='tablist'][class] {
  margin-block: 0;
  padding: 0;
}

dt {
  font-weight: var(--font-medium);
}

dt + dd {
  margin-block-start: var(--space-xs);
}

dd + dt {
  margin-block-start: var(--space-s);
}

dd {
  margin-inline-start: 1.5ch;
}

blockquote {
  margin-inline: 0;
  color: var(--color-light);
}

blockquote footer {
  margin-block-start: var(--space-s);
  color: var(--color-primary);
  font-size: var(--size-step-0);
}

blockquote q {
  font-style: normal;
}

:is(video, iframe[src*='youtube'], iframe[src*='vimeo']) {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
}

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

figcaption {
  padding-block-start: 0.5em;
  font-size: var(--size-step-0);
  font-family: monospace;
}

table {
  border: var(--stroke);
  border-collapse: collapse;
  width: 100%;
}

th {
  text-align: left;
  font-weight: var(--font-bold);
  line-height: var(--leading-fine);
}

thead th {
  padding-block: var(--space-s);
}

td,
th {
  padding: var(--space-xs) var(--space-s);
}

th:not(:only-of-type) {
  border-block-end: var(--stroke);
}

th:only-of-type {
  border-inline-end: var(--stroke);
}

:is(th, td) ~ :is(th, td) {
  border-inline-start: var(--stroke);
}

tr + tr :is(th, td) {
  border-block-start: var(--stroke);
}

caption {
  caption-side: bottom;
  margin-block-start: var(--space-s);
}

a:not([class]):hover {
  text-underline-offset: 0.2lh;
}

:is(h1, h2, h3, h4) a:not([class]) {
  text-decoration-thickness: 0.1ex;
  text-underline-offset: 0.2ex;
}

:is(h1, h2, h3, h4) a:not([class]):hover {
  text-underline-offset: 0.3ex;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--focus-color, currentColor);
  outline-offset: var(--focus-offset, 0.2lh);
}

/* Firefox is the only browser that doesn't outline the whole element unless you make it display: inline-block. That in itself causes multiple flow issues so we can detect it, using its own vendor prefix and reduce focus offset
*/

@supports (-moz-appearance: none) {
  :root {
    --focus-offset: 0.08em;
  }
}

:target {
  scroll-margin-block: 5lh;
}

::selection {
  color: var(--color-dark);
  background: var(--color-light);
}

hr {
  border: none;
  border-block-start: var(--stroke);
  margin-block: var(--flow-space, var(--space-xl));
}

svg:not([class]) {
  width: auto;
  height: 1lh;
}

svg {
  flex-shrink: 0;
}

svg[role='img'][width][height] {
  width: revert;
  height: revert;
  background: var(--color-light);
  padding: var(--space-xs);
}

/* There's a .flow composition, but this prevents forms from having to have that applied where markup is harder to control in certain systems. It still uses the --flow-space variables though to make managing space easier */

form > * + * {
  margin-top: var(--flow-space, 1rem);
}

:is(input, select, textarea) {
  accent-color: var(--color-primary);
}

:is(input:not([type='checkbox'], [type='radio'], [type='color']), select, textarea) {
  padding: 0.5em 0.8em;
  border-radius: var(--radius-s);
  border: var(--stroke-solid);
  background: var(--color-dark-glare);
  color: var(--color-light);
  width: 100%;
}

:is(input:not([type='checkbox'],[type='radio'],[type='color']),select,textarea)::placeholder {
    color: var(--color-mid);
  }

label {
  line-height: var(--leading-fine);
  font-weight: var(--font-medium);
}

label::after {
  content: '\A';
  white-space: pre;
}

/* Usually label wraps checkbox and radio buttons, so we give ourselves more layout and text-flow control with flex */

label:has(input) {
  display: flex;
  align-items: baseline;
  gap: var(--space-s);
  font-weight: var(--font-normal);
}

label:has(input) + label:has(input) {
  --flow-space: var(--space-s-m);
}

/* Slightly adjusts the vertical position of the check/radio */

label:has(input) input {
  transform: translateY(-0.1ex);
}

input:disabled {
  background: var(--color-mid);
}

input:disabled,
label input:disabled + * {
  cursor: not-allowed;
}

fieldset {
  border: var(--stroke);
  padding: var(--space-s);
}

legend {
  font-weight: var(--font-medium);
  padding-inline: var(--space-xs);
}

summary {
  font-weight: var(--font-bold);
  cursor: pointer;
}

details[open] summary {
  margin-block-end: var(--space-s);
}

.nav {
	margin-block-start: var(--space-s);
	margin-block-end: var(--space-s);
	margin-inline-start: var(--space-s);
	margin-inline-end: var(--space-s);
	font-size: var(--size-step-00);
	background: #eee;
	padding: var(--space-xs) var(--space-s);
}

header.nav {
	margin-block-end: var(--space-2xl);
}

.nav.footer {
	margin-block-start: var(--space-2xl);
}

.prose {
  --flow-space: var(--space-l);
}

.prose :is(h1, h2, h3) {
  overflow-wrap: anywhere;
  hyphens: auto;
}

.prose :is(p, li, dl, figcaption, blockquote) {
  max-width: 60ch;
  text-wrap: pretty;
}

.prose :is(h1, h2, h3, h4) + *:not([class]) {
  --flow-space: var(--space-m);
}

/* Add more space on and around figures and tables */

.prose :is(figure, table),
.prose :is(figure, table) + * {
  --flow-space: var(--space-2xl);
}

/* Add more space to headings on block start */

.prose * + :is(h1, h2, h3, h4):not([class]) {
  --flow-space: var(--space-xl);
}

.prose :is(ul, ol):not([class]) li + li,
.prose :is(ul, ol):not([class]) li > :is(ol, ul) {
  --flow-space: var(--space-xs);
}

.prose hr {
  --flow-space: var(--space-2xl);
}

.prose p:first-of-type {
	font-size: var(--size-step-3);
}

.prose :is(img, picture, video) {
  border: var(--stroke-solid);
}

@media (min-width: 760px) {
  .prose :is(h1, h2, h3) {
	overflow-wrap: unset;
	hyphens: unset;
  }
}

/*
CLUSTER
More info: https://every-layout.dev/layouts/cluster/
A layout that lets you distribute items with consitent
spacing, regardless of their size

CUSTOM PROPERTIES AND CONFIGURATION
--gutter (var(--space-m)): This defines the space
between each item.

--cluster-horizontal-alignment (flex-start): How items should align
horizontally. Can be any acceptable flexbox aligmnent value.

--cluster-vertical-alignment (center): How items should align vertically.
Can be any acceptable flexbox alignment value.
*/

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gutter, var(--space-m));
  justify-content: var(--cluster-horizontal-alignment, flex-start);
  align-items: var(--cluster-vertical-alignment, center);
}

/* 
FLOW COMPOSITION 
Like the Every Layout stack: https://every-layout.dev/layouts/stack/
Info about this implementation: https://piccalil.li/blog/my-favourite-3-lines-of-css/ 
*/

.flow > * + * {
  margin-block-start: var(--flow-space, 1em);
}

/* AUTO GRID
Related Every Layout: https://every-layout.dev/layouts/grid/
More info on the flexible nature: https://piccalil.li/tutorial/create-a-responsive-grid-layout-with-no-media-queries-using-css-grid/
A flexible layout that will create an auto-fill grid with
configurable grid item sizes

CUSTOM PROPERTIES AND CONFIGURATION
--gutter (var(--space-m)): This defines the space
between each item.

--grid-min-item-size (14rem): How large each item should be
ideally, as a minimum.

--grid-placement (auto-fill): Set either auto-fit or auto-fill
to change how empty grid tracks are handled */

.grid {
  display: grid;
  grid-template-columns: repeat(
    var(--grid-placement, auto-fill),
    minmax(var(--grid-min-item-size, 16rem), 1fr)
  );
  gap: var(--gutter, var(--space-l));
}

/* A split 50/50 layout */

.grid[data-layout='50-50'] {
  --grid-placement: auto-fit;
  --grid-min-item-size: clamp(16rem, 50vw, 33rem);
}

/* Three column grid layout */

.grid[data-layout='thirds'] {
  --grid-placement: auto-fit;
  --grid-min-item-size: clamp(16rem, 33%, 20rem);
}

/*
REPEL
A little layout that pushes items away from each other where
there is space in the viewport and stacks on small viewports

CUSTOM PROPERTIES AND CONFIGURATION
--gutter (var(--space-m)): This defines the space
between each item.

--repel-vertical-alignment (center): How items should align vertically.
Can be any acceptable flexbox alignment value.
*/

.repel {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: var(--repel-vertical-alignment, center);
  gap: var(--gutter, var(--space-m));
}

.repel[data-nowrap] {
  flex-wrap: nowrap;
}

/* 
SIDEBAR
More info: https://every-layout.dev/layouts/sidebar/
A layout that allows you to have a flexible main content area
and a "fixed" width sidebar that sits on the left or right.
If there is not enough viewport space to fit both the sidebar
width *and* the main content minimum width, they will stack
on top of each other

CUSTOM PROPERTIES AND CONFIGURATION
--gutter (var(--space-size-1)): This defines the space
between the sidebar and main content.

--sidebar-target-width (20rem): How large the sidebar should be

--sidebar-content-min-width(50%): The minimum size of the main content area

EXCEPTIONS
.sidebar[data-direction='rtl']: flips the sidebar to be on the right 
*/

.sidebar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gutter, var(--space-s-l));
}

.sidebar:not([data-direction]) > :first-child {
  flex-basis: var(--sidebar-target-width, 20rem);
  flex-grow: 1;
}

.sidebar:not([data-direction]) > :last-child {
  flex-basis: 0;
  flex-grow: 999;
  min-width: var(--sidebar-content-min-width, 50%);
}

.sidebar[data-reversed] {
  flex-direction: row-reverse;
}

.sidebar[data-direction='rtl'] > :last-child {
  flex-basis: var(--sidebar-target-width, 20rem);
  flex-grow: 1;
}

.sidebar[data-direction='rtl'] > :first-child {
  flex-basis: 0;
  flex-grow: 999;
  min-width: var(--sidebar-content-min-width, 50%);
}

/*
SWITCHER
More info: https://every-layout.dev/layouts/switcher/
A layout that allows you to lay **2** items next to each other
until there is not enough horizontal space to allow that.

CUSTOM PROPERTIES AND CONFIGURATION
--gutter (var(--space-size-1)): This defines the space
between each item

--switcher-target-container-width (40rem): How large the container
needs to be to allow items to sit inline with each other

--switcher-vertical-alignment (flex-start): How items should align vertically.
Can be any acceptable flexbox alignment value.
*/

.switcher {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gutter, var(--space-l));
  align-items: var(--switcher-vertical-alignment, flex-start);
}

.switcher > * {
  flex-grow: 1;
  flex-basis: calc((var(--switcher-target-container-width, 40rem) - 100%) * 999);
}

/* Max 2 items,
so anything greater than 2 is ful width */

.switcher > :nth-child(n + 3) {
  flex-basis: 100%;
}

/*
WRAPPER COMPOSITION 
A common wrapper/container
*/

.wrapper {
  margin-inline: auto;
  max-width: var(--wrapper-max-width, 1360px);
  padding-left: var(--gutter);
  padding-right: var(--gutter);
  position: relative;
}

/* 
REGION UTILITY
Consistent block padding for page sections
*/

.region {
  padding-block: var(--region-space, var(--space-m));
  position: relative;
}

/* 
VISUALLY HIDDEN UTILITY
Info: https://piccalil.li/quick-tip/visually-hidden/ 
*/

.visually-hidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: 0;
  margin: 0;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  white-space: nowrap;
}
