/* Display types for non-table items. */
  ADDRESS, BLOCKQUOTE, BODY, DD, DIV, DL, DT, FIELDSET, 
  FRAME, FRAMESET, H1, H2, H3, H4, H5, H6, NOFRAMES, 
  OL, P, UL, APPLET, CENTER, DIR, HR, MENU, PRE
                { display: block }

HEAD, SCRIPT, TITLE { display: none }
BODY                { margin: 8px; }

/* Rules for unordered-lists */
LI                   { display: list-item }
UL[type="square"]>LI { list-style-type : square } 
UL[type="disc"]>LI   { list-style-type : disc   } 
UL[type="circle"]>LI { list-style-type : circle } 
LI[type="circle"]    { list-style-type : circle }
LI[type="square"]    { list-style-type : square }
LI[type="disc"]      { list-style-type : disc   }

OL, UL, DIR, MENU, DD  { padding-left: 40px ; margin-left: 1em }

NOBR {
  white-space: nowrap;
}

/* Map the 'align' attribute to the 'float' property. Todo: This should
 * only be done for images, tables etc. "align" can mean different things
 * for different elements.
 */
TABLE[align="left"]       { float:left } 
TABLE[align="right"]      { float:right }
TABLE[align="center"]     { 
    margin-left:auto; 
    margin-right:auto; 
    text-align:left;
}
IMG[align="left"]         { float:left }
IMG[align="right"]        { float:right }

/* If the 'align' attribute was not mapped to float by the rules above, map
 * it to 'text-align'. The rules above take precedence because of their
 * higher specificity. 
 *
 * Also the <center> tag means to center align things.
 */
[align="center"]  { text-align:center }
[align="right"]   { text-align:right }
[align="left"]    { text-align:left }
CENTER            { text-align: center }


/* Rules for unordered-lists */
/* Todo! */

TD, TH {
  padding: 1px;
  border-bottom-color: grey60;
  border-right-color: grey60;
  border-top-color: grey25;
  border-left-color: grey25;
}

/* For a horizontal line, use a table with no content. We use a table
 * instead of a block because tables are laid out around floating boxes, 
 * whereas regular blocks are not.
 */
/*
HR { 
  display: table; 
  border-top: 1px solid grey45;
  background: grey80;
  height: 1px;
  width: 100%;
  text-align: center;
  margin: 0.5em 0;
}
*/

HR {
  display: block;
  border-top:    1px solid grey45;
  border-bottom: 1px solid grey80;
  margin: 0.5em auto 0.5em auto;
}

/* Basic table tag rules. */
TABLE { 
  display: table;
  border-spacing: 2px;

  border-bottom-color: grey25;
  border-right-color: grey25;
  border-top-color: grey60;
  border-left-color: grey60;
}

TR              { display: table-row }
THEAD           { display: table-header-group }
TBODY           { display: table-row-group }
TFOOT           { display: table-footer-group }
COL             { display: table-column }
COLGROUP        { display: table-column-group }
TD, TH          { display: table-cell }
CAPTION         { display: table-caption }
TH              { font-weight: bolder; text-align: center }
CAPTION         { text-align: center }

H1              { font-size: 2em; margin: .67em 0 }
H2              { font-size: 1.5em; margin: .83em 0 }
H3              { font-size: 1.17em; margin: 1em 0 }
H4, P,
BLOCKQUOTE, UL,
FIELDSET, 
OL, DL, DIR,
MENU            { margin-top: 1.0em; margin-bottom: 1.0em }
H5              { font-size: .83em; line-height: 1.17em; margin: 1.67em 0 }
H6              { font-size: .67em; margin: 2.33em 0 }
H1, H2, H3, H4,
H5, H6, B,
STRONG          { font-weight: bolder }
BLOCKQUOTE      { margin-left: 40px; margin-right: 40px }
I, CITE, EM,
VAR, ADDRESS    { font-style: italic }
PRE, TT, CODE,
KBD, SAMP       { font-family: courier }
BIG             { font-size: 1.17em }
SMALL, SUB, SUP { font-size: .83em }
SUB             { vertical-align: sub }
SUP             { vertical-align: super }
S, STRIKE, DEL  { text-decoration: line-through }
OL              { list-style-type: decimal }
OL UL, UL OL,
UL UL, OL OL    { margin-top: 0; margin-bottom: 0 }
U, INS          { text-decoration: underline }
ABBR, ACRONYM   { font-variant: small-caps; letter-spacing: 0.1em }

/* Formatting for <pre> etc. */
PRE, PLAINTEXT, XMP { 
  display: block;
  white-space: pre;
  margin: 1em 0;
  font-family: courier;
}

/* Display properties for hyperlinks */
:link { color: darkblue; text-decoration: underline }

/* Deal with the "nowrap" HTML attribute on table cells. */
TD[nowrap] ,     TH[nowrap]     { white-space: nowrap; }
TD[nowrap="0"] , TH[nowrap="0"] { white-space: normal; }

BR { 
    display: block;
}
/* BR:before       { content: "\A" } */

/*
 * Default decorations for form items. 
 */
INPUT[type="hidden"] { display: none }

INPUT[type] { border: none }
INPUT, INPUT[type="text"], INPUT[type="password"] { 
  border: 2px solid;
  border-color: #848280 #faf9f7 #faf9f7 #848280;
}

FRAMESET {
  display: none;
}

/*
 *************************************************************************
 * Below this point are stylesheet rules for mapping presentational 
 * attributes of Html to CSS property values. Strictly speaking, this 
 * shouldn't be specified here (in the UA stylesheet), but it doesn't matter
 * in practice. See CSS 2.1 spec for more details.
 */

/* 'color' */
[color]              { color: tcl(::tkhtml::attr color -color) }
body a[href]:link    { color: tcl(::tkhtml::aa body link -color) }
body a[href]:visited { color: tcl(::tkhtml::aa body vlink -color) }

/* 'width', 'height', 'background-color' and 'font-size' */
[width]            { width:            tcl(::tkhtml::attr width -len) }
[height]           { height:           tcl(::tkhtml::attr height -len) }
basefont[size]     { font-size:        tcl(::tkhtml::attr size) }
font[size]         { font-size:        tcl(::tkhtml::attr size) }
[bgcolor]          { background-color: tcl(::tkhtml::attr bgcolor -color) }

BR[clear]          { clear: tcl(::tkhtml::attr clear) }
BR[clear="all"]    { clear: both; }

/* Standard html <img> tags - replace the node with the image at url $src */
IMG[src]              { -tkhtml-replacement-image: tcl(::tkhtml::attr src) }

/*
 * Properties of table cells (th, td):
 *
 *     'border-width'
 *     'border-style'
 *     'padding'
 *     'border-spacing'
 */
TABLE[border], TABLE[border] TD, TABLE[border] TH {
    border-top-width:     tcl(::tkhtml::aa table border -len);
    border-right-width:   tcl(::tkhtml::aa table border -len);
    border-bottom-width:  tcl(::tkhtml::aa table border -len);
    border-left-width:    tcl(::tkhtml::aa table border -len);

    border-top-style:     tcl(::tkhtml::aa table border -if solid);
    border-right-style:   tcl(::tkhtml::aa table border -if solid);
    border-bottom-style:  tcl(::tkhtml::aa table border -if solid);
    border-left-style:    tcl(::tkhtml::aa table border -if solid);
}
TABLE[border=""], TABLE[border=""] td, TABLE[border=""] th {
    border-top-width:     tcl(::tkhtml::aa table border -if 1px);
    border-right-width:   tcl(::tkhtml::aa table border -if 1px);
    border-bottom-width:  tcl(::tkhtml::aa table border -if 1px);
    border-left-width:    tcl(::tkhtml::aa table border -if 1px);
}
TABLE[cellpadding] td, TABLE[cellpadding] th {
    padding-top:    tcl(::tkhtml::aa table cellpadding -len);
    padding-right:  tcl(::tkhtml::aa table cellpadding -len);
    padding-bottom: tcl(::tkhtml::aa table cellpadding -len);
    padding-left:   tcl(::tkhtml::aa table cellpadding -len);
}
TABLE[cellspacing], table[cellspacing] {
    border-spacing: tcl(::tkhtml::attr cellspacing -len);
}

/* Map the valign attribute to the 'vertical-align' property for table 
 * cells. The default value is "middle", or use the actual value of 
 * valign if it is defined.
 */
TD,TH                        {vertical-align: middle}
TR[valign]>TD, TR[valign]>TH {vertical-align: tcl(::tkhtml::aa tr valign)}
TR>TD[valign], TR>TH[valign] {vertical-align: tcl(::tkhtml::attr  valign)}


/* Support the "text" attribute on the <body> tag */
body[text]       {color: tcl(::tkhtml::attr text -color)}

/* Allow background images to be specified using the "background" attribute.
 * According to HTML 4.01 this is only allowed for <body> elements, but
 * many websites use it arbitrarily.
 */
[background] {
    background-image: tcl(format "url(%s)" [::tkhtml::attr background])
}

/* The vspace and hspace attributes map to margins for elements of type
 * <IMG>, <OBJECT> and <APPLET> only. Note that this attribute is
 * deprecated in HTML 4.01.
 */
IMG[vspace], OBJECT[vspace], APPLET[vspace] {
    margin-top: tcl(::tkhtml::attr vspace -len);
    margin-bottom: tcl(::tkhtml::attr vspace -len);
}
IMG[hspace], OBJECT[hspace], APPLET[hspace] {
    margin-left: tcl(::tkhtml::attr hspace -len);
    margin-right: tcl(::tkhtml::attr hspace -len);
}

