]> git.cworth.org Git - lmno.games/blob - style.css
Use CSS custom properties to define named colors
[lmno.games] / style.css
1 /*\
2 |*|
3 |*| Properties for the page: colors, etc.
4 |*|
5 |*| This is intended to be the easiest section to edit
6 |*| some easy custom theming, (a custom color scheme, etc.).
7 |*|
8 \*/
9
10 :root {
11     /* Standard colors for text. */
12     --text-fg-color: #333738;
13     --text-bg-color: white;
14     --outside-page-bg-color: #333738;
15
16     /* A little color to avoid a fully monochromatic theme. */
17     --accent-color: #287789;
18     --accent-color-bright: #44c7ef;
19
20     /* Some colors intended to convey semnatics. */
21     --warning-color: #ffa92a;
22     --danger-color: #f56257;
23     --danger-color-dark: #bc2822;
24 }
25
26 /*\
27 |*|
28 |*| Core elements: Sizing and padding
29 |*|
30 \*/
31
32 body {
33     line-height: 1.25;
34     font-family: sans-serif;
35 }
36
37 h1 {
38     font-size: 150%;
39     font-weight: bold;
40 }
41
42 h2 {
43     font-size: 110%;
44     font-weight: bold;
45 }
46
47 /*\
48 |*|
49 |*| Overall page layout
50 |*|
51 |*| Assumes: Top-level div with id="page" for all content
52 |*|
53 \*/
54
55 /* Mobile-first: At small sized we have a white background and use the
56  * entire screen width for the page (so the background color of the
57  * body is not visible anywhere). */
58 body {
59     background-color: var(--outside-page-bg-color);
60 }
61
62 #page {
63     background-color: var(--text-bg-color);
64 }
65
66 /* For a small screen (in either width or height) change the
67  * background of the body element to white so the application always
68  * appears as if it is "full screen".
69  */
70 @media screen and (max-width: 500px) and (max-height: 860px) {
71     body {
72         background-color: var(--text-bg-color);
73     }
74 }
75
76 /* We never let the page content get larger than a large fixed width.
77  *
78  * And when the screen is wide enough, we can afford some "wasted"
79  * space on either side of the page content. This starts at 0 for a
80  * 620px wide page up to 50px on either side for a 820px wide page.
81  *
82  * Note: This 820px width for the page includes the padding so the
83  * actual content is only ever as wide as 720px.
84  *
85  * Wider than that and we start to see the background on either side
86  * of the page content.
87  */
88 #page {
89     box-sizing: border-box;
90     max-width: 820px;
91     margin-left: auto;
92     margin-right: auto;
93     padding-top: 0;
94     padding-bottom: 0;
95     padding-left: 1em;
96     padding-right: 1em;
97 }
98
99 @media screen and (min-width: 620px) and (max-width: 820px) {
100     #page {
101         padding-left: calc(1em + (100% - 820px)/2);
102         padding-right: calc(1em + (100% - 820px)/2);
103     }
104 }
105
106 @media screen and (min-width: 820px) {
107     #page {
108         padding-left: calc(1em + 50px);
109         padding-right: calc(1em + 50px);
110     }
111 }
112
113 /* The calculations for height are different. We don't have any
114  * vertical centering, so instead we have only some fixed padding on
115  * the top. Then, the margin which allows the background to be visible
116  * on the top and bottom starts appearing at a viewport height of 648
117  * and tops out at a size of 36px.
118  */
119 #page {
120     min-height: 500px;
121     padding-top: 1em;
122 }
123
124 @media screen and (min-height: 648px) and (max-height: 720px) {
125     #page {
126         margin-top: calc((100vh - 648px)/2);
127         margin-bottom: calc((100vh - 648px)/2);
128     }
129 }
130
131 @media screen and (min-height: 720px) {
132     #page {
133         margin-top: 36px;
134         margin-bottom: 36px;
135     }
136 }
137
138 /*\
139 |*|
140 |*| Responsive form layout
141 |*|
142 \*/
143
144 /*
145  *
146  * Within the form, fields can be placed in <div> elements with
147  * class "form-field". Each can also have an additional class of one
148  * of "small", "medium", or "large". These classes will be used to
149  * select either a 1- or 2-column layout for each row depending on the
150  * width of the screen.
151  *
152  * Expected layout is as follows:
153  *
154  *   "large"   rows: 1-column on all devices
155  *
156  *   "medium"  rows: 2-column on wide displays (laptop/desktop/tablet)
157  *                   1-column on small display (phones)
158  *
159  *   "small"   rows: 2-column on all devices
160  *
161  * Finally, a class of either "left" or "right" will select which
162  * column the field should appear in for fields that end up in 2
163  * columns.
164  */
165 form {
166     max-width: 100%;
167     display: grid;
168     grid-template-columns: 1fr 1fr;
169     grid-column-gap: 1em;
170 }
171
172 .form-field.small.left,.form-field.medium.left {
173     grid-column-start: 1;
174 }
175
176 .form-field.small.right,.form-field.medium.right {
177     grid-column-start: 2;
178 }
179
180 .form-field.large {
181     grid-column-start: 1;
182     grid-column-end: span 2;
183 }
184
185 /* For a narrow screen, use a single-column for medium form fields. */
186 @media screen and (max-width: 600px) {
187     .form-field.medium.left,.form-field.medium.right {
188         grid-column-start: 1;
189         grid-column-end: span 2
190     }
191 }
192
193 /*\
194 |*|
195 |*| Styling for form input fields
196 |*|
197 \*/
198
199 label {
200     font-size: 125%;
201 }
202
203 input {
204     box-sizing: border-box;
205     font-size: 125%;
206     padding: 0.5em;
207     width: 100%;
208     border: 1px solid var(--accent-color);
209     border-radius: 4px;
210 }
211
212 input:focus {
213     border: 2px solid var(--accent-color-bright);
214 }
215
216 button {
217     display: inline-block;
218     border-radius: 4px;
219     background-color: var(--accent-color);
220     border: none;
221     color: white;
222     text-align: center;
223     font-size: 125%;
224     margin-top: .25em;
225     padding-top: 0.25em;
226     padding-bottom: 0.25em;
227     width: 200px;
228 }
229
230 button:hover {
231     transform: translateY(-1px);
232     background-color: var(--accent-color-bright);
233 }
234
235 :focus {
236     outline: none;
237 }
238
239 ::-moz-focus-inner {
240     border: 0;
241 }
242
243 /*\
244 |*|
245 |*| Styling for a message area
246 |*|
247 \*/
248
249 /* Default message severity is "info" but can be overriden. */
250 .message {
251     padding: 1em;
252     background-color: var(--accent-color-bright);
253     color: white;
254     transition: 0.3s;
255     margin-bottom: 0.5em;
256     font-weight: bold;
257     border-radius: 4px;
258     position: relative;
259 }
260
261 .success {
262     background-color: var(--accent-color-bright);
263 }
264
265 .warning {
266     background-color: var(--warning-color);
267 }
268
269 .danger {
270     background-color: var(--danger-color);
271 }
272
273 .hide-button {
274     color: white;
275     font-size: 125%;
276     font-weight: bold;
277     cursor: pointer;
278     position: absolute;
279     right: 0.5em;
280     top: 0;
281 }
282
283 .hide-button:hover {
284     color: var(--danger-color-dark);
285 }