]> git.draconx.ca Git - homepage.git/blobdiff - content/style.scss
cdecl99-1.3 bash-5 hotfix
[homepage.git] / content / style.scss
index f71a6a37846b1f4bc48a40a1aa25f2b6e6222178..17aff0ba0352f3a0ccf5ab9117e82c2c6e27e11e 100644 (file)
@@ -1,7 +1,7 @@
-/*
+/*!
  * Nick's web site: default stylesheet
  *
- * Copyright © 2018-2020 Nick Bowler
+ * Copyright © 2018-2022 Nick Bowler
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-// colour definitions
-$backgroundcolour:  #ffffff;
-$foregroundcolour:  #000000;
+@import "lib/colourmap.scss";
 
-$linkdefaultcolour: #0000cd;
-$linkactivecolour:  #ff0000;
-$linkvisitedcolour: #800080;
+@include defcolours
+    ( $background:  #ffffff #000000
+    , $foreground:  #000000 #ffffff
 
-$ruledefaultcolour: #d3d3d3;
-$rulestrongcolour:  #696969;
+    , $linkdefault: #0000cd #a3aaff
+    , $linkactive:  #ff0000
+    , $linkvisited: #800080 #e493f7
+    , $focusring:   #628cb2
 
-$annotationcolour:  #708090;
+    , $annotation:  #708090
+    , $tableshade:  #f5f5f5 #101010
 
-$tableshadecolour:  #f5f5f5;
+    , $ruledefault: #d3d3d3 #494949
+    , $rulestrong:  #696969 #939393
+    );
 
 @mixin header_size($maxwidth, $fontsize) {
     font-size: $fontsize;
     max-width: 1em * ($maxwidth / $fontsize);
 }
 
+html { @include usecolours($background-color: background); }
 body {
-    background-color: $backgroundcolour;
-    color: $foregroundcolour;
+    @include usecolours($color: foreground);
     font-family: sans-serif;
     margin: 1em;
 }
 
-a:link { color: $linkdefaultcolour; }
-a:visited { color: $linkvisitedcolour; }
-a:active { color: $linkactivecolour; }
+a:link {
+    @include usecolours($color: linkdefault, $border-color: linkdefault);
+}
+a:visited {
+    @include usecolours($color: linkvisited, $border-color: linkvisited);
+}
+a:active {
+    @include usecolours($color: linkactive, $border-color: linkactive);
+}
+
+@supports (outline-style: auto) {
+    a:link { border-width: 0; }
+    a:focus { @include usecolour(outline, focusring, auto); }
+    li, td, dt { &>a:link { border: solid 1px transparent; } }
+}
 
 h1 { @include header_size(60em, 2em); }
 h2 { @include header_size(60em, 1.5em); }
 h5 { @include header_size(60em, 1em); }
 
-p>img { max-width: 40em; width: 100%; height: auto; }
+h1, h2 { abbr { text-decoration: none; } }
+
+@supports (display: grid) {
+    .gallery {
+        display: grid;
+        grid-column-gap: 1em;
+        grid-template-columns: repeat( auto-fill, minmax(18em, 1fr) );
+        align-items: center;
+
+        p.img { margin: 0.5em 0; }
+    }
+
+    @media (max-width: 45em) {
+        .inline.gallery {
+            display: block;
+            p.img {
+                a { max-width: 24em; }
+                margin: 1em 0;
+            }
+        }
+    }
+}
+
+p.img {
+    text-align: center;
+
+    img {
+        vertical-align: bottom;
+        max-width: 40em;
+        width: 100%;
+        height: auto;
+    }
+
+    a {
+        text-decoration: none;
+        display: inline-block;
+        border: solid 2px;
+    }
+
+    a.left { margin: 0 1em 0.5em 0; float: left; clear: left; }
+    a.right { margin: 0 0 0.5em 1em; float: right; clear: right; }
+    a.left, a.right {
+        @media (max-width: 45em) { float: none; margin: 0; }
+
+        max-width: 24em;
+    }
+
+    small {
+        @include usecolours($color: foreground);
+        @media (max-width: 24em) { text-align: left; }
+        padding: 0.5ex;
+        display: block;
+        display: -moz-inline-box;
+        display: inline-block;
+        text-align: justify;
+        font-size: 0.9em;
+    }
+}
 
 p, dt, dd, li {
     text-align: justify;
+    @media (max-width: 28em) { text-align: left; }
     padding: 0;
     margin: 0;
 }
@@ -67,6 +140,10 @@ p, table, div, ul, ol, dl, hr {
 }
 
 p, table, body>div, h5 { margin: 1em 0; }
+blockquote {
+    @media (max-width: 28em) { margin: 1em 0.5em; }
+    margin: 1em;
+}
 
 li { margin: 0 0 0 2em; }
 dd { margin: 0 0 0 1em; }
@@ -75,29 +152,39 @@ hr {
     clear: both;
     margin: 0.5em 0;
     border: 0;
-    border-top: 1px solid $ruledefaultcolour;
+    @include usecolour(border-top, ruledefault, 1px solid);
 }
 
 kbd {
     font-family: monospace;
     font-size: 0.95em;
     &:before { content: "% "; }
+    &.ok:before { content: "ok "; }
+    &>span { white-space: nowrap; }
+
+    blockquote & {
+        display: block;
+        & + br { display: none; }
+        text-align: left;
+        padding-left: 3em;
+        text-indent: -3em;
+    }
 }
 
 .permalink {
+    @include usecolours($color: annotation);
     font-size: small;
-    color: $annotationcolour;
 
     a:link, a:visited { color: inherit; }
-}
-@media not screen {
-    .permalink { visibility: hidden; }
+    a:active { @include usecolours($color: linkactive); }
+    @media not screen { visibility: hidden; }
 }
 
 // General table styles.
 table {
-    border: 1px solid $ruledefaultcolour;
+    @include usecolour(border-top, ruledefault, 1px solid);
     border-collapse: collapse;
+    clear: both;
     width: 100%;
 }
 
@@ -117,17 +204,20 @@ td, th {
     margin: 0;
 }
 
-thead>tr, tbody>tr { border: solid $ruledefaultcolour; }
-th, thead>tr { border-bottom: 1px solid $rulestrongcolour; }
+thead>tr, tbody>tr { @include usecolour(border, ruledefault, solid); }
+th, thead>tr { @include usecolour(border-bottom, rulestrong, 1px solid); }
+tbody+tbody { @include usecolour(border-bottom, ruledefault, 1px solid); }
 *>table, *>th { border: none; }
 thead>tr { border-width: 1px; }
 tbody>tr { border-width: 0 1px; }
 
-td + td { box-shadow: -1px 0 $backgroundcolour; }
+td + td {
+    @include usecolour(box-shadow, background, -1px 0);
+}
 
 tbody>tr {
-    &:nth-of-type(even) { background-color: $tableshadecolour; }
-    &:last-child { border-bottom: solid 1px $ruledefaultcolour; }
+    &:nth-of-type(even) { @include usecolours($background-color: tableshade); }
+    &:last-child { @include usecolour(border-bottom, ruledefault, solid 1px); }
 }
 
 // Specific table styles
@@ -138,6 +228,194 @@ table.cc {
     }
 }
 
+// CSS rules for sortable clicky table headers: Update the display of
+// the table based on the current state.  Each column has its own set
+// nearly-identical rules, only the class names differ.
+//
+// The clickytables.xsl stylesheet generates two inputs for each column.
+// These inputs are siblings of the table and all precede it in document
+// order.  Moreover, the inputs for a column are ordered with respect to
+// each other, in this sequence:
+//
+//   input.clicky-NAME     -- checked iff NAME is selected for sorting.
+//   input.clicky-NAME-rev -- checked to select reverse order.
+//
+// One of the column selection inputs will have a 'checked' attribute to
+// indicate the default order.  This input is always first in document
+// order.  No other inputs begin checked.
+//
+// The table itself consists of a thead (where the header labels are
+// located) and two tbody elements.  The bulk of these rules relate
+// to updating the headers to visually indicate the current state.
+//
+// A sortable column's th element has the .clicky-NAME class, matching
+// its corresponding inputs, and has two label children.  The first label
+// is visible only when the column is unselected, and is linked to the
+// .clicky-NAME input to activate that column.  The second label is visible
+// only on the selected column and is linked to the .clicky-NAME-rev input
+// to toggle the reverse order.
+//
+// For the table body, the first tbody contains the default ordering
+// and is not styled by these rules (except to hide it when alternate
+// orderings are selected).  The second tbody contains rows for all
+// alternate orderings, and is revealed by these rules.  When revealed,
+// rows with the NAMEfwd or NAMErev class (for the forward and reverse
+// orderings, respectively) are shown and other rows are hidden.
+
+$clickynames: name, date, size;
+@each $col in $clickynames {
+    input.clicky-#{$col} {
+        &:checked {
+            &~table {
+                // Update table header state
+                & th.clicky-#{$col} {
+                    label~label {
+                        display: -moz-inline-box !important;
+                        display: inline-block !important;
+                    }
+                    label { display: none; }
+                }
+
+                // Show only appropriate items from the sort body (forward)
+                &>tbody+tbody>tr.#{$col}fwd { display: table-row; }
+                &>tbody+tbody>tr { display: none; }
+
+                // Unhide sort body
+                &>tbody {
+                    &+tbody { display: table-row-group !important; }
+                    display: none;
+                }
+            }
+
+            // reverse state for selected sort column
+            &~input.clicky-#{$col}-rev {
+                &:checked ~ table {
+                    // Show only appropriate items from sort body (reversed)
+                    &>tbody+tbody>tr.#{$col}rev { display: table-row; }
+                    &>tbody+tbody>tr { display: none; }
+
+                    // Unhide sort body
+                    &>tbody {
+                        &+tbody { display: table-row-group !important; }
+                        display: none;
+                    }
+                }
+
+                // Unhide to allow keyboard navigation to this input
+                display: block !important;
+            }
+        }
+
+        // If default input element is the only one selected, match it to
+        // return to default view (overriding the changes above).  It is
+        // always the first input element among all the sibling elements.
+        // This seems to interoperate better than using the [checked] or
+        // :first-of-type selectors.
+        @at-root &:first-child, :not(input)+& {
+            &:checked~table>tbody {
+                &+tbody { display: none !important; }
+                display: table-row-group;
+            }
+        }
+
+        // Unhide to allow keyboard navigation
+        display: block !important;
+        pointer-events: none;
+        position: absolute;
+        opacity: 0;
+        z-index: -1;
+    }
+
+    input.clicky-#{$col}-rev {
+        &:checked ~ table {
+            // Update table header state
+            & th.clicky-#{$col} {
+                .svg+.svg {
+                    display: -moz-inline-box !important;
+                    display: inline-block !important;
+                }
+                .svg { display: none; }
+            }
+        }
+
+        pointer-events: none;
+        position: absolute;
+        opacity: 0;
+        z-index: -2;
+    }
+
+    $focuslabel: ":focus ~ table th.clicky-#{$col}>label~label";
+    #{"input.clicky-#{$col+$focuslabel}"}>span:first-child
+    , #{"input.clicky-#{$col}-rev#{$focuslabel}"} .svg
+    {
+        @include usecolours($border-color: foreground);
+        @at-root { @supports (outline-style: auto) { & {
+            @include usecolour(outline, focusring, auto);
+            border-color: transparent !important;
+        }}}
+    }
+}
+
+thead.clicky label {
+    white-space: nowrap;
+    line-height: 1.5em;
+    cursor: pointer;
+
+    &>* {
+        display: -moz-inline-box;
+        display: inline-block;
+        border: 1px dotted transparent;
+        vertical-align: middle;
+    }
+
+    // Expand the first label a bit so the table (hopefully)
+    // does not reshape as columns are selected.
+    &:first-child {
+        margin-right: 1.75em;
+        padding-right: 2px;
+    }
+
+    &:active { @include usecolours($color: linkactive); }
+    &:first-child:active>span, &~label:active>.svg {
+        @include usecolours($border-color: linkactive);
+        @at-root { @supports (outline-style: auto) { & {
+            @include usecolour(outline, focusring, auto);
+            border-color: transparent;
+        }}}
+    }
+
+    .svg {
+        margin-left: 0.25em;
+    }
+
+    .svg, svg, img.svgfallback {
+        height: 1.5em;
+        width: auto;
+    }
+    .svg svg { width: 1.5em; }
+}
+
+table.filelist {
+    &>*>tr>*:first-child {
+        &+* { width: 50%; }
+        // chrome doesn't like width: 0 for some reason
+        width: 0.1px;
+    }
+
+    tbody {
+        .svg, svg, img.svgfallback {
+            vertical-align: middle;
+            height: 1.5em;
+            width: auto;
+        }
+
+        .svg {
+            svg { width: 1.5em; }
+            display: inline-block;
+        }
+    }
+}
+
 // Site header rules
 #breadcrumbs>*, #sitetitle>* { font-size: 0.8em; }
 #breadcrumbs {
@@ -171,9 +449,11 @@ table.cc {
     }
 }
 
-#footer p { color: $annotationcolour; }
+#footer p { @include usecolours($color: annotation); }
 #article-info p { font-style: italic; }
 
+.wbr:after { content: "\200b"; }
+
 // "unordered" lists with explicit ordering in content
 ul.ordered > {
     li { list-style: none; }
@@ -195,6 +475,25 @@ ul.ordered > {
     #sitetitle * { float: none; }
     #footer { padding: 0 1em; }
 }
-@media (max-width: 28em) {
-    * { text-align: left; }
+
+// lighten icon shadows in dark mode
+@media (prefers-color-scheme: dark) {
+    svg.icons { path.shadow, g.shadow>* { opacity: 0.7; } }
+    svg.icons .shadow>stop { stop-color: #aaa; }
+    svg.return path.shadow { opacity: 0.45; }
+}
+
+// page-specific dark mode styles
+@media (prefers-color-scheme: dark) and (min-width: 35em) {
+    #page_weblog_responsive_tables {
+        @each $tN in t6 t7 t8 {
+            ##{$tN}>tbody>tr.#{$tN}-split {
+                @include usecolour_dark_(border-bottom, ruledefault);
+
+                &:nth-of-type(odd) ~ tr:nth-of-type(odd) {
+                    @include usecolour_dark_(background-color, tableshade);
+                }
+            }
+        }
+    }
 }