forked from phc/website
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
website/src/styles/typography.scss

241 lines
4.9 KiB
SCSS

@function pow($number, $exponent) {
$value: 1;
@if $exponent > 0 {
@for $i from 1 through $exponent {
$value: $value * $number;
}
}
@return $value;
}
@mixin geometric-headings {
$base-font-size: 16px;
$heading-scale: 1.25;
@for $i from 1 through 5 {
$factor: pow($heading-scale, 5 - $i);
h#{$i} {
font-size: $base-font-size * $factor;
font-family: var(--font-title);
font-weight: 700;
margin-bottom: 0.25rem;
}
// p + h#{$i} {
// margin-top: 0.75rem * $factor;
// }
}
}
@layer typography {
@include geometric-headings;
.text {
// text-align: justify;
// hyphens: auto;
&.center {
text-align: center;
}
& {
line-height: 1.5;
}
& > * {
max-width: 46rem;
}
pre,
code {
background: color-mix(in lab, var(--card-base-internal, #ededed), #fff 35%) !important;
// background: color-mix(in lab, var(--zone-color), #fff 75%) !important;
// background: var(--code-bg, #00000022) !important;
font-family: var(--font-mono);
font-weight: 400;
font-size: 16px;
}
code {
border-radius: 0.25rem;
padding: 0.125rem 0.3rem;
}
pre {
margin: 2rem auto;
padding: 0.5rem 1rem;
// width: 100%;
max-width: 80ch;
width: fit-content;
line-height: 1.5;
border-radius: 0.25rem;
box-shadow: 0.25rem 0.25rem 0 0 #333;
border: 2px solid #333;
code {
padding: 0;
}
@media screen and (max-width: $screen-desktop-min) {
width: calc(100vw - 2rem);
max-width: none;
}
}
p {
line-height: 1.75;
margin: var(--paragraph-margin, 1rem) auto;
}
// p + p {
// margin-top: 1rem;
// }
// h1 + p,
// h2 + p,
// h3 + p,
// h4 + p {
// margin-top: 1rem;
// }
// p:has(+ h1, + h2, + h3, + h4) {
// margin-bottom: 1rem;
// }
p[align='center'] {
margin: 1.5rem 0;
a {
// background: color-mix(in hsl, var(--card-base-internal, #ededed), #fff 20%);
background: hsl(from var(--card-base-internal, #ededed) h calc(s + 10) calc(l - 10));
padding: 0.5rem;
border-radius: 0.25rem;
box-shadow: 0.25rem 0.25rem 0 0 #333;
border: 2px solid #333;
}
}
img {
display: block;
margin: 0 auto;
@include neo-brutalist-card(2px);
&.fill {
width: 100%;
max-width: 20rem;
}
&.small {
max-width: 5rem;
}
&.flat {
border: none;
box-shadow: none;
}
}
p:first-child {
margin-top: 0;
}
p:last-child {
margin-bottom: 0;
}
strong {
font-weight: 600;
}
em {
font-style: italic;
}
@include geometric-headings;
h1 {
margin-bottom: 2rem;
text-align: center;
}
h1,
h2,
h3,
h4 {
font-weight: 700;
color: #333;
// HACK: Trick to fix anchor links with sticky header
padding-top: 7rem;
margin-top: -6.5rem;
}
h1,
h2,
h3,
h4,
ol,
ul {
margin-left: auto;
margin-right: auto;
}
ol,
ul {
margin-bottom: var(--paragraph-margin, 1rem);
padding-left: 1.5rem;
p {
--paragraph-margin: 0.5rem;
}
}
a,
a:visited {
color: var(--zone-color, #1e6733);
font-weight: 600;
&:hover {
text-decoration: underline 2px solid;
}
}
blockquote {
margin: 1rem auto;
padding: 0.5rem 1rem;
border-left: 0.25rem solid #0006;
background: color-mix(in lab, var(--card-base-internal, #ededed), #fff 35%);
p {
margin: 0;
}
}
hr {
max-width: calc(100vw - 4rem);
width: 40ch;
margin: 3rem auto 2.75rem;
border: none;
border-top: 2px solid #0003;
}
@media screen and (max-width: $screen-desktop-min) {
& > * {
margin: 0 0.75rem;
}
}
}
}